Sendmail Guide
Sendmail Guide
SendmailTM implements a general purpose internetwork mail routing facility under the UNIX operating system. It is not tied to any one transport protocol its function may be likened to a crossbar switch, relaying messages from one domain into another. In the process, it can do a limited amount of message header editing to put the message into a format that is appropriate for the receiving domain. All of this is done under the control of a conguration le. Due to the requirements of exibility for sendmail, the conguration le can seem somewhat unapproachable. However, there are only a few basic congurations for most sites, for which standard conguration les have been supplied. Most other congurations can be built by adjusting an existing conguration le incrementally. Sendmail is based on RFC821 (Simple Mail Transport Protocol), RFC822 (Internet Mail Headers Format), RFC974 (MX routing), RFC1123 (Internet Host Requirements), RFC2045 (MIME), RFC1869 (SMTP Service Extensions), RFC1652 (SMTP 8BITMIME Extension), RFC1870 (SMTP SIZE Extension), RFC1891 (SMTP Delivery Status Notications), RFC1892 (Multipart/Report), RFC1893 (Enhanced Mail System Status Codes), RFC1894 (Delivery Status Notications), RFC1985 (SMTP Service Extension for Remote Message Queue Starting), RFC2033 (Local Message Transmission Protocol), RFC2034 (SMTP Service Extension for Returning Enhanced Error Codes), RFC2476 (Message Submission), RFC2487 (SMTP Service Extension for Secure SMTP over TLS), and RFC2554 (SMTP Service Extension for Authentication). However, since sendmail is designed to work in a wider world, in many cases it can be congured to exceed these protocols. These cases are described herein. Although sendmail is intended to run without the need for monitoring, it has a number of features that may be used to monitor or adjust the operation under unusual circumstances. These features are described. Section one describes how to do a basic sendmail installation. Section two explains the day-to-day information you should know to maintain your mail system. If you have a relatively normal site, these two sections should contain sufcient information for you to install sendmail and keep it happy. Section three describes some parameters that may be safely tweaked. Section four has information regarding the command line arguments. Section ve contains the nitty-gritty information about the conguration le. This section is for masochists and people who must write their own conguration le. Section six describes conguration that can be done at compile time. The appendixes give a brief but detailed explanation of a
DISCLAIMER: This documentation is under modication. Sendmail is a trademark of Sendmail, Inc.
SMM:08-1
SMM:08-2
SMM:08-7
1. BASIC INSTALLATION There are two basic steps to installing sendmail. First, you have to compile and install the binary. If sendmail has already been ported to your operating system that should be simple. Second, you must build a run-time conguration le. This is a le that sendmail reads when it starts up that describes the mailers it knows about, how to parse addresses, how to rewrite the message header, and the settings of various options. Although the conguration le can be quite complex, a conguration can usually be built using an M4-based conguration language. The remainder of this section will describe the installation of sendmail assuming you can use one of the existing congurations and that the standard installation parameters are acceptable. All pathnames and examples are given from the root of the sendmail subtree, normally /usr/src/usr.sbin/sendmail on 4.4BSD. If you are loading this off the tape, continue with the next section. If you have a running binary already on your system, you should probably skip to section 1.2. 1.1. Compiling Sendmail All sendmail source is in the sendmail subdirectory. To compile sendmail, cd into the sendmail directory and type ./Build This will leave the binary in an appropriately named subdirectory, e.g., obj.BSD-OS.2.1.i386. It works for multiple object versions compiled out of the same directory. 1.1.1. Tweaking the Build Invocation You can give parameters on the Build command. In most cases these are only used when the obj.* directory is rst created. These commands include: L libdirs A list of directories to search for libraries. I incdirs A list of directories to search for include les. E envar=value Set an environment variable to an indicated value before compiling. c Create a new obj.* tree before running. f sitecong Read the indicated site conguration le. If this parameter is not specied, Build includes all of the les $BUILDTOOLS/Site/site.$oscf.m4 and $BUILDTOOLS/Site/site.cong.m4, where $BUILDTOOLS is normally ../devtools and $oscf is the same name as used on the obj.* directory. See below for a description of the site conguration le. S Skip auto-conguration. Build will avoid auto-detecting libraries if this is set. All libraries and map denitions must be specied in the site conguration le.
Any other parameters are passed to the make program. 1.1.2. Creating a Site Conguration File (This section is not yet complete. For now, see the le devtools/README for details.) See sendmail/README for various compilation ags that can be set.
SMM:08-8
1.1.3. Tweaking the Makele Sendmail supports two different formats for the local (on disk) version of databases, notably the aliases database. At least one of these should be dened if at all possible. NDBM The new DBM format, available on nearly all systems around today. This was the preferred format prior to 4.4BSD. It allows such complex things as multiple databases and closing a currently open database. The Berkeley DB package. If you have this, use it. It allows long records, multiple open databases, real in-memory caching, and so forth. You can dene this in conjunction with NDBM; if you do, old alias databases are read, but when a new database is created it will be in NEWDB format. As a nasty hack, if you have NEWDB, NDBM, and NIS dened, and if the alias le name includes the substring /yp/, sendmail will create both new and old versions of the alias le during a newalias command. This is required because the Sun NIS/YP system reads the DBM version of the alias le. Its ugly as sin, but it works.
NEWDB
If neither of these are dened, sendmail reads the alias le into memory on every invocation. This can be slow and should be avoided. There are also several methods for remote database access: NIS NISPLUS NETINFO HESIOD Suns Network Information Services (formerly YP). Suns NIS+ services. NeXTs NetInfo service. Hesiod service (from Athena).
Other compilation ags are set in conf.h and should be predened for you unless you are porting to a new environment. 1.1.4. Compilation and installation After making the local system conguration described above, You should be able to compile and install the system. The script Build is the best approach on most systems: ./Build This will use uname(1) to create a custom Makele for your environment. If you are installing in the standard places, you should be able to install using ./Build install This should install the binary in /usr/sbin and create links from /usr/bin/newaliases and /usr/bin/mailq to /usr/sbin/sendmail. On 4.4BSD systems it will also format and install man pages. 1.2. Conguration Files Sendmail cannot operate without a conguration le. The conguration denes the mail delivery mechanisms understood at this site, how to access them, how to forward email to remote mail systems, and a number of tuning parameters. This conguration le is detailed in the later portion of this document. The sendmail conguration can be daunting at rst. The world is complex, and the mail conguration reects that. The distribution includes an m4-based conguration package that hides a lot of the complexity. These conguration les are simpler than old versions largely because the world has become simpler; in particular, text-based host les are ofcially eliminated, obviating the need to hide hosts behind a registered internet gateway.
SMM:08-9
These les also assume that most of your neighbors use domain-based UUCP addressing; that is, instead of naming hosts as host!user they will use host.domain!user. The conguration les can be customized to work around this, but it is more complex. Our conguration les are processed by m4 to facilitate local customization; the directory cf of the sendmail distribution directory contains the source les. This directory contains several subdirectories: cf Both site-dependent and site-independent descriptions of hosts. These can be literal host names (e.g., ucbvax.mc) when the hosts are gateways or more general descriptions (such as generic-solaris2.mc as a general description of an SMTPconnected host running Solaris 2.x. Files ending .mc (Master Conguration) are the input descriptions; the output is in the corresponding .cf le. The general structure of these les is described below. Site-dependent subdomain descriptions. These are tied to the way your organization wants to do addressing. For example, domain/CS.Berkeley.EDU.m4 is our description for hosts in the CS.Berkeley.EDU subdomain. These are referenced using the DOMAIN m4 macro in the .mc le. Denitions of specic features that some particular host in your site might want. These are referenced using the FEATURE m4 macro. An example feature is use_cw_le (which tells sendmail to read an /etc/mail/local-host-names le on startup to nd the set of local names). Local hacks, referenced using the HACK m4 macro. Try to avoid these. The point of having them here is to make it clear that they smell. Site-independent m4(1) include les that have information common to all conguration les. This can be thought of as a #include directory. Denitions of mailers, referenced using the MAILER m4 macro. The mailer types that are known in this distribution are fax, local, smtp, uucp, and usenet. For example, to include support for the UUCP-based mailers, use MAILER(uucp). Denitions describing various operating system environments (such as the location of support les). These are referenced using the OSTYPE m4 macro. Shell les used by the m4 build process. You shouldnt have to mess with these. Local UUCP connectivity information. This directory has been supplanted by the mailertable feature; any new congurations should use that feature to do UUCP (and other) routing.
domain
feature
hack m4 mailer
ostype sh sitecong
If you are in a new domain (e.g., a company), you will probably want to create a cf/domain le for your domain. This consists primarily of relay denitions and features you want enabled sitewide: for example, Berkeleys domain denition denes relays for BitNET and UUCP. These are specic to Berkeley, and should be fully-qualied internet-style domain names. Please check to make certain they are reasonable for your domain. Subdomains at Berkeley are also represented in the cf/domain directory. For example, the domain CS.Berkeley.EDU is the Computer Science subdomain, EECS.Berkeley.EDU is the Electrical Engineering and Computer Sciences subdomain, and S2K.Berkeley.EDU is the Sequoia 2000 subdomain. You will probably have to add an entry to this directory to be appropriate for your domain. You will have to use or create .mc les in the cf/cf subdirectory for your hosts. This is detailed in the cf/README le.
SMM:08-10
1.3. Details of Installation Files This subsection describes the les that comprise the sendmail installation. 1.3.1. /usr/sbin/sendmail The binary for sendmail is located in /usr/sbin1. It should be setuid root. For security reasons, /, /usr, and /usr/sbin should be owned by root, mode 7552. 1.3.2. /etc/mail/sendmail.cf This is the conguration le for sendmail3. This is the only non-library le name compiled into sendmail4. The conguration le is normally created using the distribution les described above. If you have a particularly unusual system conguration you may need to create a special version. The format of this le is detailed in later sections of this document. 1.3.3. /usr/bin/newaliases The newaliases command should just be a link to sendmail: rm f /usr/bin/newaliases ln s /usr/sbin/sendmail /usr/bin/newaliases This can be installed in whatever search path you prefer for your system. 1.3.4. /usr/bin/hoststat The hoststat command should just be a link to sendmail, in a fashion similar to newaliases. This command lists the status of the last mail transaction with all remote hosts. The v ag will prevent the status display from being truncated. It functions only when the HostStatusDirectory option is set. 1.3.5. /usr/bin/purgestat This command is also a link to sendmail. It ushes expired (Timeout.hoststatus) information that is stored in the HostStatusDirectory tree. 1.3.6. /var/spool/mqueue The directory /var/spool/mqueue should be created to hold the mail queue. This directory should be mode 700 and owned by root. The actual path of this directory is dened in the Q option of the sendmail.cf le. To use multiple queues, supply a value ending with an asterisk. For example, /var/spool/mqueue/qd* will use all of the directories or symbolic links to directories beginning with qd in /var/spool/mqueue as queue directories. Do not change the queue directory structure while
1 This is usually /usr/sbin on 4.4BSD and newer systems; many systems install it in /usr/lib. I understand it is in /usr/ucblib on System V Release 4.
Some vendors ship them owned by bin; this creates a security hole that is not actually related to sendmail. Other important directories that should have restrictive ownerships and permissions are /bin, /usr/bin, /etc, /etc/mail, /usr/etc, /lib, and /usr/lib.
3 Actually, the pathname varies depending on the operating system; /etc/mail is the preferred directory. Some older systems install it in /usr/lib/sendmail.cf, and Ive also seen it in /usr/ucblib. If you want to move this le, add -D_PATH_SENDMAILCF=\"/le/name\" to the ags passed to the C compiler. Moving this le is not recommended: other programs and scripts know of this location. 4 The system libraries can reference other les; in particular, system library subroutines that sendmail calls probably reference /etc/passwd and /etc/resolv.conf.
SMM:08-11
sendmail is running. If these directories have subdirectories or symbolic links to directories named qf, df, and xf, then these will be used for the different queue le types. That is, the data les are stored in the df subdirectory, the transcript les are stored in the xf subdirectory, and all others are stored in the qf subdirectory. 1.3.7. /var/spool/mqueue/.hoststat This is a typical value for the HostStatusDirectory option, containing one le per host that this sendmail has chatted with recently. It is normally a subdirectory of mqueue. 1.3.8. /etc/mail/aliases* The system aliases are held in /etc/mail/aliases. A sample is given in sendmail/aliases which includes some aliases which must be dened: cp lib/aliases /etc/mail/aliases edit /etc/mail/aliases You should extend this le with any aliases that are apropos to your system. Normally sendmail looks at a database version of the les, stored either in /etc/mail/aliases.dir and /etc/mail/aliases.pag or /etc/mail/aliases.db depending on which database package you are using. The actual path of this le is dened in the AliasFile option of the sendmail.cf le. 1.3.9. /etc/rc or /etc/init.d/sendmail It will be necessary to start up the sendmail daemon when your system reboots. This daemon performs two functions: it listens on the SMTP socket for connections (to receive mail from a remote system) and it processes the queue periodically to insure that mail gets delivered when hosts come up. Add the following lines to /etc/rc (or /etc/rc.local as appropriate) in the area where it is starting up the daemons on a BSD-base system, or on a System-V-based system in one of the startup les, typically /etc/init.d/sendmail: if [ f /usr/sbin/sendmail a f /etc/mail/sendmail.cf ]; then (cd /var/spool/mqueue; rm f [lnx]f*) /usr/sbin/sendmail bd q30m & echo n sendmail >/dev/console The cd and rm commands insure that all lock les have been removed; extraneous lock les may be left around if the system goes down in the middle of processing a message. The line that actually invokes sendmail has two ags: bd causes it to listen on the SMTP port, and q30m causes it to run the queue every half hour. Some people use a more complex startup script, removing zero length qf les and df les for which there is no qf le. For example, see Figure 1 for an example of a complex script which does this clean up. If you are not running a version of UNIX that supports Berkeley TCP/IP, do not include the bd ag. 1.3.10. /etc/mail/helple This is the help le used by the SMTP HELP command. It should be copied from sendmail/helple:
SMM:08-12
#!/bin/sh # remove zero length qf les for qfle in qf* do if [ r $qfle ] then if [ ! s $qfle ] then echo n " <zero: $qfle>" > /dev/console rm f $qfle done # rename tf les to be qf if the qf does not exist for tfle in tf* do qfle=echo $tfle | sed s/t/q/ if [ r $tfle a ! f $qfle ] then echo n " <recovering: $tfle>" > /dev/console mv $tfle $qfle else if [ f $tfle ] then echo n " <extra: $tfle>" > /dev/console rm f $tfle done # remove df les with no corresponding qf les for dfle in df* do qfle=echo $dfle | sed s/d/q/ if [ r $dfle a ! f $qfle ] then echo n " <incomplete: $dfle>" > /dev/console mv $dfle echo $dfle | sed s/d/D/ done # announce les that have been saved during disaster recovery for xfle in [A-Z]f* do if [ f $xfle ] then echo n " <panic: $xfle>" > /dev/console done Figure 1 A complex startup script
SMM:08-13
cp sendmail/helple /etc/mail/helple The actual path of this le is dened in the HelpFile option of the sendmail.cf le. 1.3.11. /etc/mail/statistics If you wish to collect statistics about your mail trafc, you should create the le /etc/mail/statistics: cp /dev/null /etc/mail/statistics chmod 644 /etc/mail/statistics This le does not grow. It is printed with the program mailstats/mailstats.c. The actual path of this le is dened in the S option of the sendmail.cf le. 1.3.12. /usr/bin/mailq If sendmail is invoked as mailq, it will simulate the bp ag (i.e., sendmail will print the contents of the mail queue; see below). This should be a link to /usr/sbin/sendmail. 2. NORMAL OPERATIONS 2.1. The System Log The system log is supported by the syslogd (8) program. All messages from sendmail are logged under the LOG_MAIL facility5. 2.1.1. Format Each line in the system log consists of a timestamp, the name of the machine that generated it (for logging from several machines over the local area network), the word sendmail:, and a message6. Most messages are a sequence of name=value pairs. The two most common lines are logged when a message is processed. The rst logs the receipt of a message; there will be exactly one of these per message. Some elds may be omitted if they do not contain interesting information. Fields are: from size class pri nrcpts msgid proto daemon relay The envelope sender address. The size of the message in bytes. The class (i.e., numeric precedence) of the message. The initial message priority (used for queue sorting). The number of envelope recipients for this message (after aliasing and forwarding). The message id of the message (from the header). The protocol used to receive this message (e.g., ESMTP or UUCP) The daemon name from the DaemonPortOptions setting. The machine from which it was received.
There is also one line logged per delivery attempt (so there can be several per message if delivery is deferred or there are multiple recipients). Fields are:
5 6
Except on Ultrix, which does not support facilities in the syslog. This format may vary slightly if your vendor has changed the syntax.
SMM:08-14
A comma-separated list of the recipients to this mailer. The controlling user, that is, the name of the user whose credentials we use for delivery. The total delay between the time this message was received and the current delivery attempt. The amount of time needed in this delivery attempt (normally indicative of the speed of the connection). The name of the mailer used to deliver to this recipient. The name of the host that actually accepted (or rejected) this recipient. The enhanced error code (RFC2034) if available. The delivery status.
Not all elds are present in all messages; for example, the relay is not listed for local deliveries. 2.1.2. Levels If you have syslogd (8) or an equivalent installed, you will be able to do logging. There is a large amount of information that can be logged. The log is arranged as a succession of levels. At the lowest level only extremely strange situations are logged. At the highest level, even the most mundane and uninteresting events are recorded for posterity. As a convention, log levels under ten are considered generally useful; log levels above 64 are reserved for debugging purposes. Levels from 1164 are reserved for verbose information that some sites might want. A complete description of the log levels is given in section 4.6. 2.2. Dumping State You can ask sendmail to log a dump of the open les and the connection cache by sending it a
SIGUSR1 signal. The results are logged at LOG_DEBUG priority.
2.3. The Mail Queue Sometimes a host cannot handle a message immediately. For example, it may be down or overloaded, causing it to refuse connections. The sending host is then expected to save this message in its mail queue and attempt to deliver it later. Under normal conditions the mail queue will be processed transparently. However, you may nd that manual intervention is sometimes necessary. For example, if a major host is down for a period of time the queue may become clogged. Although sendmail ought to recover gracefully when the host comes up, you may nd performance unacceptably bad in the meantime. 2.3.1. Printing the queue The contents of the queue can be printed using the mailq command (or by specifying the bp ag to sendmail): mailq This will produce a listing of the queue ids, the size of the message, the date the message entered the queue, and the sender and recipients. 2.3.2. Forcing the queue Sendmail should run the queue automatically at intervals. When using multiple queues, a separate process will be created to run each of the queues unless the queue run is initiated by a user with the verbose ag. The algorithm is to read and sort the queue, and then to attempt to process all jobs in order. When it attempts to run the job, sendmail rst checks to see if the job
SMM:08-15
is locked. If so, it ignores the job. There is no attempt to insure that only one queue processor exists at any time, since there is no guarantee that a job cannot take forever to process (however, sendmail does include heuristics to try to abort jobs that are taking absurd amounts of time; technically, this violates RFC 821, but is blessed by RFC 1123). Due to the locking algorithm, it is impossible for one job to freeze the entire queue. However, an uncooperative recipient host or a program recipient that never returns can accumulate many processes in your system. Unfortunately, there is no completely general way to solve this. In some cases, you may nd that a major host going down for a couple of days may create a prohibitively large queue. This will result in sendmail spending an inordinate amount of time sorting the queue. This situation can be xed by moving the queue to a temporary place and creating a new queue. The old queue can be run later when the offending host returns to service. To do this, it is acceptable to move the entire queue directory: cd /var/spool mv mqueue omqueue; mkdir mqueue; chmod 700 mqueue You should then kill the existing daemon (since it will still be processing in the old queue directory) and create a new daemon. To run the old mail queue, run the following command: /usr/sbin/sendmail oQ/var/spool/omqueue q The oQ ag species an alternate queue directory and the q ag says to just run every job in the queue. If you have a tendency toward voyeurism, you can use the v ag to watch what is going on. When the queue is nally emptied, you can remove the directory: rmdir /var/spool/omqueue 2.4. Disk Based Connection Information Sendmail stores a large amount of information about each remote system it has connected to in memory. It is now possible to preserve some of this information on disk as well, by using the HostStatusDirectory option, so that it may be shared between several invocations of sendmail. This allows mail to be queued immediately or skipped during a queue run if there has been a recent failure in connecting to a remote machine. Additionally enabling SingleThreadDelivery has the added effect of single-threading mail delivery to a destination. This can be quite helpful if the remote machine is running an SMTP server that is easily overloaded or cannot accept more than a single connection at a time, but can cause some messages to be punted to a future queue run. It also applies to all hosts, so setting this because you have one machine on site that runs some software that is easily overrun can cause mail to other hosts to be slowed down. If this option is set, you probably want to set the MinQueueAge option as well and run the queue fairly frequently; this way jobs that are skipped because another sendmail is talking to the same host will be tried again quickly rather than being delayed for a long time. The disk based host information is stored in a subdirectory of the mqueue directory called .hoststat7. Removing this directory and its subdirectories has an effect similar to the purgestat command and is completely safe. However, purgestat only removes expired (Timeout.hoststatus) data. The information in these directories can be perused with the hoststat command, which will
7
This is the usual value of the HostStatusDirectory option; it can, of course, go anywhere you like in your lesystem.
SMM:08-16
indicate the host name, the last access, and the status of that access. An asterisk in the left most column indicates that a sendmail process currently has the host locked for mail delivery. The disk based connection information is treated the same way as memory based connection information for the purpose of timeouts. By default, information about host failures is valid for 30 minutes. This can be adjusted with the Timeout.hoststatus option. The connection information stored on disk may be expired at any time with the purgestat command or by invoking sendmail with the bH switch. The connection information may be viewed with the hoststat command or by invoking sendmail with the bh switch. 2.5. The Service Switch The implementation of certain system services such as host and user name lookup is controlled by the service switch. If the host operating system supports such a switch, and sendmail knows about it, sendmail will use the native version. Ultrix, Solaris, and DEC OSF/1 are examples of such systems8. If the underlying operating system does not support a service switch (e.g., SunOS 4.X, HPUX, BSD) then sendmail will provide a stub implementation. The ServiceSwitchFile option points to the name of a le that has the service denitions. Each line has the name of a service and the possible implementations of that service. For example, the le: hosts dns les nis aliases les nis will ask sendmail to look for hosts in the Domain Name System rst. If the requested host name is not found, it tries local les, and if that fails it tries NIS. Similarly, when looking for aliases it will try the local les rst followed by NIS. Service switches are not completely integrated. For example, despite the fact that the host entry listed in the above example species to look in NIS, on SunOS this wont happen because the system implementation of gethostbyname (3) doesnt understand this. If there is enough demand sendmail may reimplement gethostbyname (3), gethostbyaddr (3), getpwent (3), and the other system routines that would be necessary to make this work seamlessly. 2.6. The Alias Database After recipient addresses are read from the SMTP connection or command line they are parsed by ruleset 0, which must resolve to a {mailer, host, address} triple. If the ags selected by the mailer include the A (aliasable) ag, the address part of the triple is looked up as the key (i.e., the left hand side) into the alias database. If there is a match, the address is deleted from the send queue and all addresses on the right hand side of the alias are added in place of the alias that was found. This is a recursive operation, so aliases found in the right hand side of the alias are similarly expanded. The alias database exists in two forms. One is a text form, maintained in the le /etc/mail/aliases. The aliases are of the form name: name1, name2, ... Only local names may be aliased; e.g., [email protected]: [email protected]
8 HP-UX 10 has service switch support, but since the APIs are apparently not available in the libraries sendmail does not use the native service switch in this release.
SMM:08-17
will not have the desired effect (except on prep.ai.MIT.EDU, and they probably dont want me)9. Aliases may be continued by starting any continuation lines with a space or a tab or by putting a backslash directly before the newline. Blank lines and lines beginning with a sharp sign (#) are comments. The second form is processed by the ndbm (3)10 or the Berkeley DB library. This form is in the le /etc/mail/aliases.db (if using NEWDB) or /etc/mail/aliases.dir and /etc/mail/aliases.pag (if using NDBM). This is the form that sendmail actually uses to resolve aliases. This technique is used to improve performance. The control of search order is actually set by the service switch. Essentially, the entry O AliasFile=switch:aliases is always added as the rst alias entry; also, the rst alias le name without a class (e.g., without nis: on the front) will be used as the name of the le for a les entry in the aliases switch. For example, if the conguration le contains O AliasFile=/etc/mail/aliases and the service switch contains aliases nis les nisplus then aliases will rst be searched in the NIS database, then in /etc/mail/aliases, then in the NIS+ database. You can also use NIS-based alias les. For example, the specication: O AliasFile=/etc/mail/aliases O AliasFile=nis:[email protected] will rst search the /etc/mail/aliases le and then the map named mail.aliases in my.nis.domain. Warning: if you build your own NIS-based alias les, be sure to provide the l ag to makedbm(8) to map upper case letters in the keys to lower case; otherwise, aliases with upper case letters in their names wont match incoming addresses. Additional ags can be added after the colon exactly like a K line for example: O AliasFile=nis:N [email protected] will search the appropriate NIS map and always include null bytes in the key. Also: O AliasFile=nis:f [email protected] will prevent sendmail from downcasing the key before the alias lookup. 2.6.1. Rebuilding the alias database The hash or dbm version of the database may be rebuilt explicitly by executing the command newaliases This is equivalent to giving sendmail the bi ag: /usr/sbin/sendmail bi If the RebuildAliases (old D) option is specied in the conguration, sendmail will rebuild the alias database automatically if possible when it is out of date. Auto-rebuild can be dangerous on heavily loaded machines with large alias les; if it might take more than the rebuild timeout (option AliasWait, old a, which is normally ve minutes) to rebuild the
9
Actually, any mailer that has the A mailer ag set will permit aliasing; this is normally limited to the local mailer. The gdbm package does not work.
10
SMM:08-18
database, there is a chance that several processes will start the rebuild process simultaneously. If you have multiple aliases databases specied, the bi ag rebuilds all the database types it understands (for example, it can rebuild NDBM databases but not NIS databases). 2.6.2. Potential problems There are a number of problems that can occur with the alias database. They all result from a sendmail process accessing the DBM version while it is only partially built. This can happen under two circumstances: One process accesses the database while another process is rebuilding it, or the process rebuilding the database dies (due to being killed or a system crash) before completing the rebuild. Sendmail has three techniques to try to relieve these problems. First, it ignores interrupts while rebuilding the database; this avoids the problem of someone aborting the process leaving a partially rebuilt database. Second, it locks the database source le during the rebuild but that may not work over NFS or if the le is unwritable. Third, at the end of the rebuild it adds an alias of the form @: @ (which is not normally legal). Before sendmail will access the database, it checks to insure that this entry exists11. 2.6.3. List owners If an error occurs on sending to a certain address, say x, sendmail will look for an alias of the form owner-x to receive the errors. This is typically useful for a mailing list where the submitter of the list has no control over the maintenance of the list itself; in this case the list maintainer would be the owner of the list. For example: unix-wizards: eric@ucbarpa, wnj@monet, nosuchuser, sam@matisse owner-unix-wizards: unix-wizards-request unix-wizards-request: eric@ucbarpa would cause eric@ucbarpa to get the error that will occur when someone sends to unix-wizards due to the inclusion of nosuchuser on the list. List owners also cause the envelope sender address to be modied. The contents of the owner alias are used if they point to a single user, otherwise the name of the alias itself is used. For this reason, and to obey Internet conventions, the owner- address normally points at the -request address; this causes messages to go out with the typical Internet convention of using list-request as the return address. 2.7. User Information Database If you have a version of sendmail with the user information database compiled in, and you have specied one or more databases using the U option, the databases will be searched for a user:maildrop entry. If found, the mail will be sent to the specied address. 2.8. Per-User Forwarding (.forward Files) As an alternative to the alias database, any user may put a le with the name .forward in his or her home directory. If this le exists, sendmail redirects mail for that user to the list of addresses listed in the .forward le. Note that aliases are fully expanded before forward les are referenced.
11
The AliasWait option is required in the conguration for this action to occur. This should normally be specied.
SMM:08-19
For example, if the home directory for user mckusick has a .forward le with contents: mckusick@ernie kirk@calder then any mail arriving for mckusick will be redirected to the specied accounts. Actually, the conguration le denes a sequence of lenames to check. By default, this is the users .forward le, but can be dened to be more generally using the ForwardPath option. If you change this, you will have to inform your user base of the change; .forward is pretty well incorporated into the collective subconscious. 2.9. Special Header Lines Several header lines have special interpretations dened by the conguration le. Others have interpretations built into sendmail that cannot be changed without changing the code. These builtins are described here. 2.9.1. Errors-To: If errors occur anywhere during processing, this header will cause error messages to go to the listed addresses. This is intended for mailing lists. The Errors-To: header was created in the bad old days when UUCP didnt understand the distinction between an envelope and a header; this was a hack to provide what should now be passed as the envelope sender address. It should go away. It is only used if the UseErrorsTo option is set. The Errors-To: header is ofcially deprecated and will go away in a future release. 2.9.2. Apparently-To: RFC 822 requires at least one recipient eld (To:, Cc:, or Bcc: line) in every message. If a message comes in with no recipients listed in the message then sendmail will adjust the header based on the NoRecipientAction option. One of the possible actions is to add an ApparentlyTo: header line for any recipients it is aware of. The Apparently-To: header is non-standard and is deprecated. 2.9.3. Precedence The Precedence: header can be used as a crude control of message priority. It tweaks the sort order in the queue and can be congured to change the message timeout values. The precedence of a message also controls how delivery status notications (DSNs) are processed for that message. 2.10. IDENT Protocol Support Sendmail supports the IDENT protocol as dened in RFC 1413. Note that the RFC states a client should wait at least 30 seconds for a response. The default Timeout.ident is 5 seconds as many sites have adopted the practice of dropping IDENT queries. This has lead to delays processing mail. Although this enhances identication of the author of an email message by doing a call back to the originating system to include the owner of a particular TCP connection in the audit trail it is in no sense perfect; a determined forger can easily spoof the IDENT protocol. The following description is excerpted from RFC 1413: 6. Security Considerations The information returned by this protocol is at most as trustworthy as the host providing it OR the organization operating the host. For example, a PC in an open lab has few if any controls on it to prevent a user from having this protocol return any identier the user wants.
SMM:08-20
Likewise, if the host has been compromised the information returned may be completely erroneous and misleading. The Identication Protocol is not intended as an authorization or access control protocol. At best, it provides some additional auditing information with respect to TCP connections. At worst, it can provide misleading, incorrect, or maliciously incorrect information. The use of the information returned by this protocol for other than auditing is strongly discouraged. Specically, using Identication Protocol information to make access control decisions - either as the primary method (i.e., no other checks) or as an adjunct to other methods may result in a weakening of normal host security. An Identication server may reveal information about users, entities, objects or processes which might normally be considered private. An Identication server provides service which is a rough analog of the CallerID services provided by some phone companies and many of the same privacy considerations and arguments that apply to the CallerID service apply to Identication. If you wouldnt run a "nger" server due to privacy considerations you may not want to run this protocol. In some cases your system may not work properly with IDENT support due to a bug in the TCP/IP implementation. The symptoms will be that for some hosts the SMTP connection will be closed almost immediately. If this is true or if you do not want to use IDENT, you should set the IDENT timeout to zero; this will disable the IDENT protocol. 3. ARGUMENTS The complete list of arguments to sendmail is described in detail in Appendix A. Some important arguments are described here. 3.1. Queue Interval The amount of time between forking a process to run through the queue is dened by the q ag. If you run with delivery mode set to i or b this can be relatively large, since it will only be relevant when a host that was down comes back up. If you run in q mode it should be relatively short, since it denes the maximum amount of time that a message may sit in the queue. (See also the MinQueueAge option.) RFC 1123 section 5.3.1.1 says that this value should be at least 30 minutes (although that probably doesnt make sense if you use queue-only mode). 3.2. Daemon Mode If you allow incoming mail over an IPC connection, you should have a daemon running. This should be set by your /etc/rc le using the bd ag. The bd ag and the q ag may be combined in one call: /usr/sbin/sendmail bd q30m An alternative approach is to invoke sendmail from inetd(8) (use the bs ag to ask sendmail to speak SMTP on its standard input and output). This works and allows you to wrap sendmail in a TCP wrapper program, but may be a bit slower since the conguration le has to be re-read on every message that comes in. If you do this, you still need to have a sendmail running to ush the queue: /usr/sbin/sendmail q30m 3.3. Forcing the Queue In some cases you may nd that the queue has gotten clogged for some reason. You can force a queue run using the q ag (with no value). It is entertaining to use the v ag (verbose) when
SMM:08-21
this is done to watch what happens: /usr/sbin/sendmail q v You can also limit the jobs to those with a particular queue identier, sender, or recipient using one of the queue modiers. For example, qRberkeley restricts the queue run to jobs that have the string berkeley somewhere in one of the recipient addresses. Similarly, qSstring limits the run to particular senders and qIstring limits it to particular queue identiers. 3.4. Debugging There are a fairly large number of debug ags built into sendmail. Each debug ag has a number and a level, where higher levels means to print out more information. The convention is that levels greater than nine are absurd, i.e., they print out so much information that you wouldnt normally want to see them except for debugging that particular piece of code. Debug ags are set using the d option; the syntax is: debug-ag: d debug-list debug-list: debug-option [ , debug-option ]* debug-option: debug-range [ . debug-level ] debug-range: integer | integer integer debug-level: integer where spaces are for reading ease only. For example, d12 d12.3 d317 d317.4 Set ag 12 to level 1 Set ag 12 to level 3 Set ags 3 through 17 to level 1 Set ags 3 through 17 to level 4
For a complete list of the available debug ags you will have to look at the code and the TRACEFLAGS le in the sendmail distribution (they are too dynamic to keep this document up to date). 3.5. Changing the Values of Options Options can be overridden using the o or O command line ags. For example, /usr/sbin/sendmail oT2m sets the T (timeout) option to two minutes for this run only; the equivalent line using the long option name is /usr/sbin/sendmail -OTimeout.queuereturn=2m Some options have security implications. Sendmail allows you to set these, but relinquishes its setuid root permissions thereafter12. 3.6. Trying a Different Conguration File An alternative conguration le can be specied using the C ag; for example, /usr/sbin/sendmail Ctest.cf oQ/tmp/mqueue uses the conguration le test.cf instead of the default /etc/mail/sendmail.cf. If the C ag has no value it defaults to sendmail.cf in the current directory. Sendmail gives up its setuid root permissions when you use this ag, so it is common to use a publicly writable directory (such as /tmp) as the queue directory (QueueDirectory or Q option)
That is, it sets its effective uid to the real uid; thus, if you are executing as root, as from roots crontab le or during system startup the root permissions will still be honored.
12
SMM:08-22
while testing. 3.7. Logging Trafc Many SMTP implementations do not fully implement the protocol. For example, some personal computer based SMTPs do not understand continuation lines in reply codes. These can be very hard to trace. If you suspect such a problem, you can set trafc logging using the X ag. For example, /usr/sbin/sendmail X /tmp/trafc bd will log all trafc in the le /tmp/trafc. This logs a lot of data very quickly and should NEVER be used during normal operations. After starting up such a daemon, force the errant implementation to send a message to your host. All message trafc in and out of sendmail, including the incoming SMTP trafc, will be logged in this le. 3.8. Testing Conguration Files When you build a conguration table, you can do a certain amount of testing using the test mode of sendmail. For example, you could invoke sendmail as: sendmail bt Ctest.cf which would read the conguration le test.cf and enter test mode. In this mode, you enter lines of the form: rwset address where rwset is the rewriting set you want to use and address is an address to apply the set to. Test mode shows you the steps it takes as it proceeds, nally showing you the address it ends up with. You may use a comma separated list of rwsets for sequential application of rules to an input. For example: 3,1,21,4 monet:bollard rst applies ruleset three to the input monet:bollard. Ruleset one is then applied to the output of ruleset three, followed similarly by rulesets twenty-one and four. If you need more detail, you can also use the d21 ag to turn on more debugging. For example, sendmail bt d21.99 turns on an incredible amount of information; a single word address is probably going to print out several pages worth of information. You should be warned that internally, sendmail applies ruleset 3 to all addresses. In test mode you will have to do that manually. For example, older versions allowed you to use 0 [email protected] This version requires that you use: 3,0 [email protected] As of version 8.7, some other syntaxes are available in test mode: .D x value denes macro x to have the indicated value. This is useful when debugging rules that use the $&x syntax. .C c value adds the indicated value to class c. .S ruleset dumps the contents of the indicated ruleset. d debug-spec is equivalent to the command-line ag.
SMM:08-23
3.9. Persistent Host Status Information When HostStatusDirectory is enabled, information about the status of hosts is maintained on disk and can thus be shared between different instantiations of sendmail. The status of the last connection with each remote host may be viewed with the command: sendmail bh This information may be ushed with the command: sendmail bH Flushing the information prevents new sendmail processes from loading it, but does not prevent existing processes from using the status information that they already have. 4. TUNING There are a number of conguration parameters you may want to change, depending on the requirements of your site. Most of these are set using an option in the conguration le. For example, the line O Timeout.queuereturn=5d sets option Timeout.queuereturn to the value 5d (ve days). Most of these options have appropriate defaults for most sites. However, sites having very high mail loads may nd they need to tune them as appropriate for their mail load. In particular, sites experiencing a large number of small messages, many of which are delivered to many recipients, may nd that they need to adjust the parameters dealing with queue priorities. All versions of sendmail prior to 8.7 had single character option names. As of 8.7, options have long (multi-character names). Although old short names are still accepted, most new options do not have short equivalents. This section only describes the options you are most likely to want to tweak; read section 5 for more details. 4.1. Timeouts All time intervals are set using a scaled syntax. For example, 10m represents ten minutes, whereas 2h30m represents two and a half hours. The full set of scales is: s m h d w seconds minutes hours days weeks
4.1.1. Queue interval The argument to the q ag species how often a sub-daemon will run the queue. This is typically set to between fteen minutes and one hour. If not set, or set to zero, the queue will not be run automatically. RFC 1123 section 5.3.1.1 recommends that this be at least 30 minutes. 4.1.2. Read timeouts Timeouts all have option names Timeout.suboption. The recognized suboptions, their default values, and the minimum values allowed by RFC 1123 section 5.3.2 are: connect The time to wait for an SMTP connection to open (the connect(2) system call) [0, unspecied]. If zero, uses the kernel default. In no case can this option extend the timeout longer than the kernel provides, but it can shorten it. This is to get around kernels that provide an absurdly long connection timeout (90 minutes in one case).
SMM:08-24
iconnect
The same as connect, except it applies only to the initial attempt to connect to a host for a given message [0, unspecied]. The concept is that this should be very short (a few seconds); hosts that are well connected and responsive will thus be serviced immediately. Hosts that are slow will not hold up other deliveries in the initial delivery attempt. The wait for the initial 220 greeting message [5m, 5m]. The wait for a reply from a HELO or EHLO command [5m, unspecied]. This may require a host name lookup, so ve minutes is probably a reasonable minimum. The wait for a reply from a MAIL command [10m, 5m]. The wait for a reply from a RCPT command [1h, 5m]. This should be long because it could be pointing at a list that takes a long time to expand (see below). The wait for a reply from a DATA command [5m, 2m]. The wait for reading a data block (that is, the body of the message). [1h, 3m]. This should be long because it also applies to programs piping input to sendmail which have no guarantee of promptness. The wait for a reply from the dot terminating a message. [1h, 10m]. If this is shorter than the time actually needed for the receiver to deliver the message, duplicates will be generated. This is discussed in RFC 1047. The wait for a reply from a RSET command [5m, unspecied]. The wait for a reply from a QUIT command [2m, unspecied]. The wait for a reply from miscellaneous (but short) commands such as NOOP (no-operation) and VERB (go into verbose mode). [2m, unspecied]. In server SMTP, the time to wait for another command. [1h, 5m]. The timeout waiting for a reply to an IDENT query [30s13, unspecied]. The timeout for opening .forward and :include: les [60s, none]. The timeout for a complete control socket transaction to complete [2m, none]. How long status information about a host (e.g., host down) will be cached before it is considered stale [30m, unspecied]. The resolvers retransmission time interval (in seconds) [varies]. Sets both Timeout.resolver.retrans.rst and Timeout.resolver.retrans.normal.
initial helo
mail rcpt
datainit datablock
datanal
resolver.retrans.rst The resolvers retransmission time interval (in seconds) for the rst attempt to deliver a message [varies]. resolver.retrans.normal The resolvers retransmission time interval (in seconds) for all resolver lookups except the rst delivery attempt [varies]. resolver.retry The number of times to retransmit a resolver query. Sets both Timeout.resolver.retry.rst and Timeout.resolver.retry.normal [varies].
resolver.retry.rst The number of times to retransmit a resolver query for the rst attempt to deliver a message [varies].
13
On some systems the default is zero to turn the protocol off entirely.
SMM:08-25
resolver.retry.normal The number of times to retransmit a resolver query for all resolver lookups except the rst delivery attempt [varies]. For compatibility with old conguration les, if no suboption is specied, all the timeouts marked with a dagger () are set to the indicated value. All but those marked with a double dagger () apply to client SMTP. Many of the RFC 1123 minimum values may well be too short. Sendmail was designed to the RFC 822 protocols, which did not specify read timeouts; hence, versions of sendmail prior to version 8.1 did not guarantee to reply to messages promptly. In particular, a RCPT command specifying a mailing list will expand and verify the entire list; a large list on a slow system may easily take more than ve minutes14. I recommend a one hour timeout since a communications failure during the RCPT phase is rare, a long timeout is not onerous and may ultimately help reduce network load and duplicated messages. For example, the lines: O Timeout.command=25m O Timeout.datablock=3h sets the server SMTP command timeout to 25 minutes and the input data block timeout to three hours. 4.1.3. Message timeouts After sitting in the queue for a few days, a message will time out. This is to insure that at least the sender is aware of the inability to send a message. The timeout is typically set to ve days. It is sometimes considered convenient to also send a warning message if the message is in the queue longer than a few hours (assuming you normally have good connectivity; if your messages normally took several hours to send you wouldnt want to do this because it wouldnt be an unusual event). These timeouts are set using the Timeout.queuereturn and Timeout.queuewarn options in the conguration le (previously both were set using the T option). If the message is submitted using the NOTIFY SMTP extension, warning messages will only be sent if NOTIFY=DELAY is specied. The queuereturn and queuewarn timeouts can be further qualied with a tag based on the Precedence: eld in the message; they must be one of urgent (indicating a positive non-zero precedence) normal (indicating a zero precedence), or non-urgent (indicating negative precedences). For example, setting Timeout.queuewarn.urgent=1h sets the warning timeout for urgent messages only to one hour. The default if no precedence is indicated is to set the timeout for all precedences. The value "now" can be used for -O Timeout.queuereturn to return entries immediately during a queue run, e.g., to bounce messages independent of their time in the queue. Since these options are global, and since you can not know a priori how long another host outside your domain will be down, a ve day timeout is recommended. This allows a recipient to x the problem even if it occurs at the beginning of a long weekend. RFC 1123 section 5.3.1.1 says that this parameter should be at least 45 days. The Timeout.queuewarn value can be piggybacked on the T option by indicating a time after which a warning message should be sent; the two timeouts are separated by a slash. For example, the line OT5d/4h
14 This verication includes looking up every address with the name server; this involves network delays, and can in some cases can be considerable.
SMM:08-26
causes email to fail after ve days, but a warning message will be sent after four hours. This should be large enough that the message will have been tried several times. 4.2. Forking During Queue Runs By setting the ForkEachJob (Y) option, sendmail will fork before each individual message while running the queue. This will prevent sendmail from consuming large amounts of memory, so it may be useful in memory-poor environments. However, if the ForkEachJob option is not set, sendmail will keep track of hosts that are down during a queue run, which can improve performance dramatically. If the ForkEachJob option is set, sendmail can not use connection caching. 4.3. Queue Priorities Every message is assigned a priority when it is rst instantiated, consisting of the message size (in bytes) offset by the message class (which is determined from the Precedence: header) times the work class factor and the number of recipients times the work recipient factor. The priority is used to order the queue. Higher numbers for the priority mean that the message will be processed later when running the queue. The message size is included so that large messages are penalized relative to small messages. The message class allows users to send high priority messages by including a Precedence: eld in their message; the value of this eld is looked up in the P lines of the conguration le. Since the number of recipients affects the amount of load a message presents to the system, this is also included into the priority. The recipient and class factors can be set in the conguration le using the RecipientFactor (y) and ClassFactor (z) options respectively. They default to 30000 (for the recipient factor) and 1800 (for the class factor). The initial priority is: pri = msgsize (class ClassFactor) + (nrcpt RecipientFactor) (Remember, higher values for this parameter actually mean that the job will be treated with lower priority.) The priority of a job can also be adjusted each time it is processed (that is, each time an attempt is made to deliver it) using the work time factor, set by the RetryFactor (Z) option. This is added to the priority, so it normally decreases the precedence of the job, on the grounds that jobs that have failed many times will tend to fail again in the future. The RetryFactor option defaults to 90000. 4.4. Load Limiting Sendmail can be asked to queue (but not deliver) mail if the system load average gets too high using the QueueLA (x) option. When the load average exceeds the value of the QueueLA option, the delivery mode is set to q (queue only) if the QueueFactor (q) option divided by the difference in the current load average and the QueueLA option plus one exceeds the priority of the message that is, the message is queued iff: pri > QueueFactor LA QueueLA + 1
The QueueFactor option defaults to 600000, so each point of load average is worth 600000 priority points (as described above). For drastic cases, the RefuseLA (X) option denes a load average at which sendmail will refuse to accept network connections. Locally generated mail (including incoming UUCP mail) is still accepted.
SMM:08-27
4.5. Delivery Mode There are a number of delivery modes that sendmail can operate in, set by the DeliveryMode (d) conguration option. These modes specify how quickly mail will be delivered. Legal modes are: i b q d deliver interactively (synchronously) deliver in background (asynchronously) queue only (dont deliver) defer delvery attempts (dont deliver)
There are tradeoffs. Mode i gives the sender the quickest feedback, but may slow down some mailers and is hardly ever necessary. Mode b delivers promptly but can cause large numbers of processes if you have a mailer that takes a long time to deliver a message. Mode q minimizes the load on your machine, but means that delivery may be delayed for up to the queue interval. Mode d is identical to mode q except that it also prevents all the early map lookups from working; it is intended for dial on demand sites where DNS lookups might cost real money. Some simple error messages (e.g., host unknown during the SMTP protocol) will be delayed using this mode. Mode b is the usual default. If you run in mode q (queue only), d (defer), or b (deliver in background) sendmail will not expand aliases and follow .forward les upon initial receipt of the mail. This speeds up the response to RCPT commands. Mode i cannot be used by the SMTP server. 4.6. Log Level The level of logging can be set for sendmail. The default using a standard conguration table is level 9. The levels are as follows: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 20 30 Minimal logging. Serious system failures and potential security problems. Lost communications (network problems) and protocol failures. Other serious failures, malformed addresses, transient forward/include errors, connection timeouts. Minor failures, out of date alias databases, connection rejections via check_ rulesets. Message collection statistics. Creation of error messages, VRFY and EXPN commands. Delivery failures (host or user unknown, etc.). Successful deliveries and alias database rebuilds. Messages being deferred (due to a host being down, etc.). Database expansion (alias, forward, and userdb lookups) and authentication information. NIS errors and end of job processing. Logs all SMTP connections. Log bad user shells, les with improper permissions, and other questionable situations. Logs refused connections. Log all incoming and outgoing SMTP commands. Logs attempts to run locked queue les. These are not errors, but can be useful to note if your queue appears to be clogged. Lost locks (only if using lockf instead of ock).
Additionally, values above 64 are reserved for extremely verbose debugging output. No normal site would ever set these.
SMM:08-28
4.7. File Modes The modes used for les depend on what functionality you want and the level of security you require. In many cases sendmail does careful checking of the modes of les and directories to avoid accidental compromise; if you want to make it possible to have group-writable support les you may need to use the DontBlameSendmail option to turn off some of these checks. 4.7.1. To suid or not to suid? Sendmail is normally installed setuid to root. At the point where it is about to exec (2) a mailer, it checks to see if the userid is zero (root); if so, it resets the userid and groupid to a default (set by the U= equate in the mailer line; if that is not set, the DefaultUser option is used). This can be overridden by setting the S ag to the mailer for mailers that are trusted and must be called as root. However, this will cause mail processing to be accounted (using sa (8)) to root rather than to the user sending the mail. If you dont make sendmail setuid to root, it will still run but you lose a lot of functionality and a lot of privacy, since youll have to make the queue directory world readable. You could also make sendmail setuid to some pseudo-user (e.g., create a user called sendmail and make sendmail setuid to that) which will x the privacy problems but not the functionality issues. It also introduces problems on some operating systems if sendmail needs to give up the setuid special privileges. Also, this isnt a guarantee of security: for example, root occasionally sends mail, and the daemon often runs as root. Note however that sendmail must run as root or the trusted user in order to create the SMTP listener socket. A middle ground is to make sendmail setuid to root, but set the RunAsUser option. This causes sendmail to become the indicated user as soon as it has done the startup that requires root privileges (primarily, opening the SMTP socket). If you use RunAsUser, the queue directory (normally /var/spool/mqueue) should be owned by that user, and all les and databases (including user .forward les, alias les, :include: les, and external databases) must be readable by that user. Also, since sendmail will not be able to change its uid, delivery to programs or les will be marked as unsafe, e.g., undeliverable, in .forward, aliases, and :include: les. Administrators can override this by setting the DontBlameSendmail option to the setting NonRootSafeAddr. RunAsUser is probably best suited for rewall congurations that dont have regular user logins. 4.7.2. Turning off security checks Sendmail is very particular about the modes of les that it reads or writes. For example, by default it will refuse to read most les that are group writable on the grounds that they might have been tampered with by someone other than the owner; it will even refuse to read les in group writable directories. If you are quite sure that your conguration is safe and you want sendmail to avoid these security checks, you can turn off certain checks using the DontBlameSendmail option. This option takes one or more names that disable checks. In the descriptions that follow, unsafe directory means a directory that is writable by anyone other than the owner. The values are: Safe No special handling. AssumeSafeChown Assume that the chown system call is restricted to root. Since some versions of UNIX permit regular users to give away their les to other users on some lesystems, sendmail often cannot assume that a given le was created by the owner, particularly when it is in a writable directory. You can set this ag if you know that le giveaway is restricted on your system. ClassFileInUnsafeDirPath When reading class les (using the F line in the conguration le), allow les that are
SMM:08-29
in unsafe directories. DontWarnForwardFileInUnsafeDirPath Prevent logging of unsafe directory path warnings for non-existent forward les. ErrorHeaderInUnsafeDirPath Allow the le named in the ErrorHeader option to be in an unsafe directory. FileDeliveryToHardLink Allow delivery to les that are hard links. FileDeliveryToSymLink Allow delivery to les that are symbolic links. ForwardFileInGroupWritableDirPath Allow .forward les in group writable directories. ForwardFileInUnsafeDirPath Allow .forward les in unsafe directories. ForwardFileInUnsafeDirPathSafe Allow a .forward le that is in an unsafe directory to include references to program and les. GroupWritableAliasFile Allow group-writable alias les. GroupWritableDirPathSafe Change the denition of unsafe directory to consider group-writable directories to be safe. World-writable directories are always unsafe. GroupWritableForwardFileSafe Accept group-writable .forward les as safe for program and le delivery. GroupWritableIncludeFileSafe Accept group-writable :include: les as safe for program and le delivery. HelpFileInUnsafeDirPath Allow the le named in the HelpFile option to be in an unsafe directory. IncludeFileInGroupWritableDirPath Allow :include: les in group writable directories. IncludeFileInUnsafeDirPath Allow :include: les in unsafe directories. IncludeFileInUnsafeDirPathSafe Allow a :include: le that is in an unsafe directory to include references to program and les. InsufcientEntropy Try to use STARTTLS even if the PRNG for OpenSSL is not properly seeded despite the security problems. LinkedAliasFileInWritableDir Allow an alias le that is a link in a writable directory. LinkedClassFileInWritableDir Allow class les that are links in writable directories. LinkedForwardFileInWritableDir Allow .forward les that are links in writable directories. LinkedIncludeFileInWritableDir Allow :include: les that are links in writable directories.
SMM:08-30
LinkedMapInWritableDir Allow map les that are links in writable directories. LinkedServiceSwitchFileInWritableDir Allow the service switch le to be a link even if the directory is writable. MapInUnsafeDirPath Allow maps (e.g., hash, btree, and dbm les) in unsafe directories. NonRootSafeAddr Do not mark le and program deliveries as unsafe if sendmail is not running with root privileges. RunProgramInUnsafeDirPath Go ahead and run programs that are in writable directories. RunWritableProgram Go ahead and run programs that are group- or world-writable. TrustStickyBit Allow group or world writable directories if the sticky bit is set on the directory. Do not set this on systems which do not honor the sticky bit on directories. WorldWritableAliasFile Accept world-writable alias les. WriteMapToHardLink Allow writes to maps that are hard links. WriteMapToSymLink Allow writes to maps that are symbolic links. WriteStatsToHardLink Allow the status le to be a hard link. WriteStatsToSymLink Allow the status le to be a symbolic link. 4.8. Connection Caching When processing the queue, sendmail will try to keep the last few open connections open to avoid startup and shutdown costs. This only applies to IPC connections. When trying to open a connection the cache is rst searched. If an open connection is found, it is probed to see if it is still active by sending a RSET command. It is not an error if this fails; instead, the connection is closed and reopened. Two parameters control the connection cache. The ConnectionCacheSize (k) option denes the number of simultaneous open connections that will be permitted. If it is set to zero, connections will be closed as quickly as possible. The default is one. This should be set as appropriate for your system size; it will limit the amount of system resources that sendmail will use during queue runs. Never set this higher than 4. The ConnectionCacheTimeout (K) option species the maximum time that any cached connection will be permitted to idle. When the idle time exceeds this value the connection is closed. This number should be small (under ten minutes) to prevent you from grabbing too many resources from other hosts. The default is ve minutes. 4.9. Name Server Access Control of host address lookups is set by the hosts service entry in your service switch le. If you are on a system that has built-in service switch support (e.g., Ultrix, Solaris, or DEC OSF/1) then your system is probably congured properly already. Otherwise, sendmail will consult the le
SMM:08-31
/etc/mail/service.switch, which should be created. Sendmail only uses two entries: hosts and aliases, although system routines may use other services (notably the passwd service for user name lookups by getpwname). However, some systems (such as SunOS 4.X) will do DNS lookups regardless of the setting of the service switch entry. In particular, the system routine gethostbyname(3) is used to look up host names, and many vendor versions try some combination of DNS, NIS, and le lookup in /etc/hosts without consulting a service switch. Sendmail makes no attempt to work around this problem, and the DNS lookup will be done anyway. If you do not have a nameserver congured at all, such as at a UUCP-only site, sendmail will get a connection refused message when it tries to connect to the name server. If the hosts switch entry has the service dns listed somewhere in the list, sendmail will interpret this to mean a temporary failure and will queue the mail for later processing; otherwise, it ignores the name server data. The same technique is used to decide whether to do MX lookups. If you want MX support, you must have dns listed as a service in the hosts switch entry. The ResolverOptions (I) option allows you to tweak name server options. The command line takes a series of ags as documented in resolver(3) (with the leading RES_ deleted). Each can be preceded by an optional + or . For example, the line O ResolverOptions=+AAONLY DNSRCH turns on the AAONLY (accept authoritative answers only) and turns off the DNSRCH (search the domain path) options. Most resolver libraries default DNSRCH, DEFNAMES, and RECURSE ags on and all others off. You can also include HasWildcardMX to specify that there is a wildcard MX record matching your domain; this turns off MX matching when canonifying names, which can lead to inappropriate canonications. Version level 1 congurations turn DNSRCH and DEFNAMES off when doing delivery lookups, but leave them on everywhere else. Version 8 of sendmail ignores them when doing canonication lookups (that is, when using $[ ... $]), and always does the search. If you dont want to do automatic name extension, dont call $[ ... $]. The search rules for $[ ... $] are somewhat different than usual. If the name being looked up has at least one dot, it always tries the unmodied name rst. If that fails, it tries the reduced search path, and lastly tries the unmodied name (but only for names without a dot, since names with a dot have already been tried). This allows names such as utc.CS to match the site in Czechoslovakia rather than the site in your local Computer Science department. It also prefers A and CNAME records over MX records that is, if it nds an MX record it makes note of it, but keeps looking. This way, if you have a wildcard MX record matching your domain, it will not assume that all names match. To completely turn off all name server access on systems without service switch support (such as SunOS 4.X) you will have to recompile with DNAMED_BIND=0 and remove lresolv from the list of libraries to be searched when linking. 4.10. Moving the Per-User Forward Files Some sites mount each users home directory from a local disk on their workstation, so that local access is fast. However, the result is that .forward le lookups are slow. In some cases, mail can even be delivered on machines inappropriately because of a le server being down. The performance can be especially bad if you run the automounter. The ForwardPath (J) option allows you to set a path of forward les. For example, the cong le line O ForwardPath=/var/forward/$u:$z/.forward.$w would rst look for a le with the same name as the users login in /var/forward; if that is not found (or is inaccessible) the le .forward.machinename in the users home directory is searched. A
SMM:08-32
truly perverse site could also search by sender by using $r, $s, or $f. If you create a directory such as /var/forward, it should be mode 1777 (that is, the sticky bit should be set). Users should create the les mode 644. Note that you must use the forwardleinunsafedirpath and forwardleinunsafedirpathsafe ags with the DontBlameSendmail option to allow forward les in a world writable directory. This might also be used as a denial of service attack (users could create forward les for other users); a better approach might be to create /var/forward mode 755 and create empty les for each user, owned by that user, mode 644. If you do this, you dont have to set the DontBlameSendmail options indicated above. 4.11. Free Space On systems that have one of the system calls in the statfs(2) family (including statvfs and ustat), you can specify a minimum number of free blocks on the queue lesystem using the MinFreeBlocks (b) option. If there are fewer than the indicated number of blocks free on the lesystem on which the queue is mounted the SMTP server will reject mail with the 452 error code. This invites the SMTP client to try again later. Beware of setting this option too high; it can cause rejection of email when that mail would be processed without difculty. 4.12. Maximum Message Size To avoid overowing your system with a large message, the MaxMessageSize option can be set to set an absolute limit on the size of any one message. This will be advertised in the ESMTP dialogue and checked during message collection. 4.13. Privacy Flags The PrivacyOptions (p) option allows you to set certain privacy ags. Actually, many of them dont give you any extra privacy, rather just insisting that client SMTP servers use the HELO command before using certain commands or adding extra headers to indicate possible spoof attempts. The option takes a series of ag names; the nal privacy is the inclusive or of those ags. For example: O PrivacyOptions=needmailhelo, noexpn insists that the HELO or EHLO command be used before a MAIL command is accepted and disables the EXPN command. The ags are detailed in section 5.6. 4.14. Send to Me Too Beginning with version 8.10, sendmail includes by default the (envelope) sender in any list expansions. For example, if matt sends to a list that contains matt as one of the members he will get a copy of the message. If the MeToo option is set to FALSE (in the conguration le or via the command line), this behavior is changed, i.e., the (envelope) sender is excluded in list expansions. 5. THE WHOLE SCOOP ON THE CONFIGURATION FILE This section describes the conguration le in detail. There is one point that should be made clear immediately: the syntax of the conguration le is designed to be reasonably easy to parse, since this is done every time sendmail starts up, rather than easy for a human to read or write. On the future project list is a conguration-le compiler.
SMM:08-33
The conguration le is organized as a series of lines, each of which begins with a single character dening the semantics for the rest of the line. Lines beginning with a space or a tab are continuation lines (although the semantics are not well dened in many places). Blank lines and lines beginning with a sharp symbol (#) are comments. 5.1. R and S Rewriting Rules The core of address parsing are the rewriting rules. These are an ordered production system. Sendmail scans through the set of rewriting rules looking for a match on the left hand side (LHS) of the rule. When a rule matches, the address is replaced by the right hand side (RHS) of the rule. There are several sets of rewriting rules. Some of the rewriting sets are used internally and must have specic semantics. Other rewriting sets do not have specically assigned semantics, and may be referenced by the mailer denitions or by other rewriting sets. The syntax of these two commands are: Sn Sets the current ruleset being collected to n. If you begin a ruleset more than once it appends to the old denition. Rlhs rhs comments The elds must be separated by at least one tab character; there may be embedded spaces in the elds. The lhs is a pattern that is applied to the input. If it matches, the input is rewritten to the rhs. The comments are ignored. Macro expansions of the form $x are performed when the conguration le is read. A literal $ can be included using $$. Expansions of the form $&x are performed at run time using a somewhat less general algorithm. This is intended only for referencing internally dened macros such as $h that are changed at runtime. 5.1.1. The left hand side The left hand side of rewriting rules contains a pattern. Normal words are simply matched directly. Metasyntax is introduced using a dollar sign. The metasymbols are: $* $+ $ $=x $x Match zero or more tokens Match one or more tokens Match exactly one token Match any phrase in class x Match any word not in class x
If any of these match, they are assigned to the symbol $n for replacement on the right hand side, where n is the index in the LHS. For example, if the LHS: $:$+ is applied to the input: UCBARPA:eric the rule will match, and the values passed to the RHS will be: $1 $2 UCBARPA eric
Additionally, the LHS can include $@ to match zero tokens. This is not bound to a $n on the RHS, and is normally only used when it stands alone in order to match the null input.
SMM:08-34
5.1.2. The right hand side When the left hand side of a rewriting rule matches, the input is deleted and replaced by the right hand side. Tokens are copied directly from the RHS unless they begin with a dollar sign. Metasymbols are: $n Substitute indenite token n from LHS $[name$] Canonicalize name $(map key $@arguments $:default $) Generalized keyed mapping function $>n Call ruleset n $#mailer Resolve to mailer $@host Specify host $:user Specify user The $n syntax substitutes the corresponding value from a $+, $, $*, $=, or $ match on the LHS. It may be used anywhere. A host name enclosed between $[ and $] is looked up in the host database(s) and replaced by the canonical name15. For example, $[ftp$] might become ftp.CS.Berkeley.EDU and $[[128.32.130.2]$] would become vangogh.CS.Berkeley.EDU. Sendmail recognizes its numeric IP address without calling the name server and replaces it with its canonical name. The $( ... $) syntax is a more general form of lookup; it uses a named map instead of an implicit map. If no lookup is found, the indicated default is inserted; if no default is specied and no lookup matches, the value is left unchanged. The arguments are passed to the map for possible use. The $>n syntax causes the remainder of the line to be substituted as usual and then passed as the argument to ruleset n. The nal value of ruleset n then becomes the substitution for this rule. The $> syntax expands everything after the ruleset name to the end of the replacement string and then passes that as the initial input to the ruleset. Recursive calls are allowed. For example, $>0 $>3 $1 expands $1, passes that to ruleset 3, and then passes the result of ruleset 3 to ruleset 0. The $# syntax should only be used in ruleset zero or a subroutine of ruleset zero. It causes evaluation of the ruleset to terminate immediately, and signals to sendmail that the address has completely resolved. The complete syntax is: $#mailer $@host $:user This species the {mailer, host, user} 3-tuple necessary to direct the mailer. If the mailer is local the host part may be omitted16. The mailer must be a single word, but the host and user may be multi-part. If the mailer is the builtin IPC mailer, the host may be a colon-separated list of hosts that are searched in order for the rst working address (exactly like MX records). The user is later rewritten by the mailer-specic envelope rewriting set and assigned to the $u macro. As a special case, if the mailer specied has the F=@ ag specied and the rst character of the $: value is @, the @ is stripped off, and a ag is set in the address descriptor that causes sendmail to not do ruleset 5 processing.
15 16
This is actually completely equivalent to $(host hostname$). In particular, a $: default can be used.
You may want to use it for special per user extensions. For example, in the address [email protected]; the +foo part is not part of the user name, and is passed to the local mailer for local use.
SMM:08-35
Normally, a rule that matches is retried, that is, the rule loops until it fails. A RHS may also be preceded by a $@ or a $: to change this behavior. A $@ prex causes the ruleset to return with the remainder of the RHS as the value. A $: prex causes the rule to terminate immediately, but the ruleset to continue; this can be used to avoid continued application of a rule. The prex is stripped before continuing. The $@ and $: prexes may precede a $> spec; for example: R$+ $: $>7 $1 matches anything, passes that to ruleset seven, and continues; the $: is necessary to avoid an innite loop. Substitution occurs in the order described, that is, parameters from the LHS are substituted, hostnames are canonicalized, subroutines are called, and nally $#, $@, and $: are processed. 5.1.3. Semantics of rewriting rule sets There are six rewriting sets that have specic semantics. Five of these are related as depicted by gure 1. Ruleset three should turn the address into canonical form. This form should have the basic syntax: local-part@host-domain-spec Ruleset three is applied by sendmail before doing anything with any address. If no @ sign is specied, then the host-domain-spec may be appended (box D in Figure 1) from the sender address (if the C ag is set in the mailer denition corresponding to the sending mailer). Ruleset zero is applied after ruleset three to addresses that are going to actually specify recipients. It must resolve to a {mailer, host, address} triple. The mailer must be dened in the mailer denitions from the conguration le. The host is dened into the $h macro for use in the argv expansion of the specied mailer.
resolved address
1 addr 3 D 2
S 4 R msg
Figure 1 Rewriting set semantics D sender domain addition S mailer-specic sender rewriting R mailer-specic recipient rewriting
SMM:08-36
Rulesets one and two are applied to all sender and recipient addresses respectively. They are applied before any specication in the mailer denition. They must never resolve. Ruleset four is applied to all addresses in the message. It is typically used to translate internal to external form. In addition, ruleset 5 is applied to all local addresses (specically, those that resolve to a mailer with the F=5 ag set) that do not have aliases. This allows a last minute hook for local names. 5.1.4. Ruleset hooks A few extra rulesets are dened as hooks that can be dened to get special features. They are all named rulesets. The check_* forms all give accept/reject status; falling off the end or returning normally is an accept, and resolving to $#error is a reject. Many of these can also resolve to the special mailer name $#discard; this accepts the message as though it were successful but then discards it without delivery. Note, this mailer can not be chosen as a mailer in ruleset 0. 5.1.4.1. check_relay The check_relay ruleset is called after a connection is accepted by the daemon. It is not called when sendmail is started using the bs option. It is passed client.host.name $| client.host.address where $| is a metacharacter separating the two parts. This ruleset can reject connections from various locations. 5.1.4.2. check_mail The check_mail ruleset is passed the user name parameter of the SMTP MAIL command. It can accept or reject the address. 5.1.4.3. check_rcpt The check_rcpt ruleset is passed the user name parameter of the SMTP RCPT command. It can accept or reject the address. 5.1.4.4. check_compat The check_compat ruleset is passed sender-address $| recipient-address where $| is a metacharacter separating the addresses. It can accept or reject mail transfer between these two addresses much like the checkcompat() function. 5.1.4.5. check_eoh The check_eoh ruleset is passed number-of-headers $| size-of-headers where $| is a metacharacter separating the numbers. These numbers can be used for size comparisons with the arith map. The ruleset is triggered after all of the headers have been read. It can be used to correlate information gathered from those headers using the macro storage map. One possible use is to check for a missing header. For example:
SMM:08-37
Kstorage macro HMessage-Id: $>CheckMessageId SCheckMessageId # Record the presence of the header R$* $: $(storage {MessageIdCheck} $@ OK $) $1 R< $+ @ $+ > $@ OK R$* $#error $: 553 Header Error Scheck_eoh # Check the macro R$* $: < $&{MessageIdCheck} > # Clear the macro for the next message R$* $: $(storage {MessageIdCheck} $) $1 # Has a Message-Id: header R< $+ > $@ OK # Allow missing Message-Id: from local mail R$* $: < $&{client_name} > R< > $@ OK R< $=w > $@ OK # Otherwise, reject the mail R$* $#error $: 553 Header Error Keep in mind the Message-Id: header is not a required header and is not a guaranteed spam indicator. This ruleset is an example and should probably not be used in production. 5.1.4.6. check_etrn The check_etrn ruleset is passed the parameter of the SMTP ETRN command. It can accept or reject the command. 5.1.4.7. check_expn The check_expn ruleset is passed the user name parameter of the SMTP EXPN command. It can accept or reject the address. 5.1.4.8. check_vrfy The check_vrfy ruleset is passed the user name parameter of the SMTP VRFY command. It can accept or reject the command. 5.1.4.9. trust_auth The trust_auth ruleset is passed the AUTH= parameter of the SMTP MAIL command. It is used to determine whether this value should be trusted. In order to make this decision, the ruleset may make use of the various ${auth_*} macros. If the ruleset does resolve to the error mailer the AUTH= parameter is not trusted and hence not passed on to the next relay. 5.1.4.10. tls_client The tls_client ruleset is called when sendmail acts as server, after a STARTTLS command has been issued, and from check_mail. The parameter is the value of ${verify} and STARTTLS or MAIL, respectively. If the ruleset does resolve to the error mailer, the appropriate error code is returned to the client.
SMM:08-38
5.1.4.11. tls_server The tls_server ruleset is called when sendmail acts as client after a STARTTLS command (should) have been issued. The parameter is the value of ${verify}. If the ruleset does resolve to the error mailer, the connection is aborted (treated as non-deliverable with a permanent or temporary error). 5.1.5. IPC mailers Some special processing occurs if the ruleset zero resolves to an IPC mailer (that is, a mailer that has [IPC] listed as the Path in the M conguration line. The host name passed after $@ has MX expansion performed if not delivering via a named socket; this looks the name up in DNS to nd alternate delivery sites. The host name can also be provided as a dotted quad in square brackets; for example: [128.32.149.78] This causes direct conversion of the numeric value to an IP host address. The host name passed in after the $@ may also be a colon-separated list of hosts. Each is separately MX expanded and the results are concatenated to make (essentially) one long MX list. The intent here is to create fake MX records that are not published in DNS for private internal networks. As a nal special case, the host name can be passed in as a text string in square brackets: [ucbvax.berkeley.edu] This form avoids the MX mapping. N.B.: This is intended only for situations where you have a network rewall or other host that will do special processing for all your mail, so that your MX record points to a gateway machine; this machine could then do direct delivery to machines within your local domain. Use of this feature directly violates RFC 1123 section 5.3.5: it should not be used lightly. 5.2. D Dene Macro Macros are named with a single character or with a word in {braces}. The names x and {x} denote the same macro for every single character x. Single character names may be selected from the entire ASCII set, but user-dened macros should be selected from the set of upper case letters only. Lower case letters and special symbols are used internally. Long names beginning with a lower case letter or a punctuation character are reserved for use by sendmail, so user-dened long macro names should begin with an upper case letter. The syntax for macro denitions is: Dx val where x is the name of the macro (which may be a single character or a word in braces) and val is the value it should have. There should be no spaces given that do not actually belong in the macro value. Macros are interpolated using the construct $x, where x is the name of the macro to be interpolated. This interpolation is done when the conguration le is read, except in M lines. The special construct $&x can be used in R lines to get deferred interpolation. Conditionals can be specied using the syntax: $?x text1 $| text2 $. This interpolates text1 if the macro $x is set and non-null, and text2 otherwise. The else ($|) clause may be omitted. Lower case macro names are reserved to have special semantics, used to pass information in or out of sendmail, and special characters are reserved to provide conditionals, etc. Upper case
SMM:08-39
names (that is, $A through $Z) are specically reserved for conguration le authors. The following macros are dened and/or used internally by sendmail for interpolation into argvs for mailers or for other contexts. The ones marked are information passed into sendmail17, the ones marked are information passed both in and out of sendmail, and the unmarked macros are passed out of sendmail but are not otherwise used internally. These macros are: $a $b $c $d $e The origination date in RFC 822 format. This is extracted from the Date: line. The current date in RFC 822 format. The hop count. This is a count of the number of Received: lines plus the value of the h command line ag. The current date in UNIX (ctime) format. (Obsolete; use SmtpGreetingMessage option instead.) The SMTP entry message. This is printed out when SMTP starts up. The rst word must be the $j macro as specied by RFC821. Defaults to $j Sendmail $v ready at $b. Commonly redened to include the conguration version number, e.g., $j Sendmail $v/$Z ready at $b The envelope sender (from) address. The sender address relative to the recipient. For example, if $f is foo, $g will be host!foo, [email protected], or whatever is appropriate for the receiving mailer. The recipient host. This is set in ruleset 0 from the $@ eld of a parsed address. The queue id, e.g., HAA12345. The ofcial domain name for this site. This is fully qualied if the full qualication can be found. It must be redened to be the fully qualied domain name if your system is not congured so that information can nd it automatically. The UUCP node name (from the uname system call). (Obsolete; use UnixFromLine option instead.) The format of the UNIX from line. Unless you have changed the UNIX mailbox format, you should not change the default, which is From $g $d. The domain part of the gethostname return value. Under normal circumstances, $j is equivalent to $w.$m. The name of the daemon (for error messages). Defaults to MAILER-DAEMON. (Obsolete: use OperatorChars option instead.) The set of operators in addresses. A list of characters which will be considered tokens and which will separate tokens when doing parsing. For example, if @ were in the $o macro, then the input a@b would be scanned as three tokens: a, @, and b. Defaults to .:@[], which is the minimum set necessary to do RFC 822 parsing; a richer set of operators is .:%@!/[], which adds support for UUCP, the %-hack, and X.400 addresses. Sendmails process id. Default format of sender address. The $q macro species how an address should appear in a message when it is defaulted. Defaults to <$g>. It is commonly redened to be $?x$x <$g>$|$g$. or $g$?x ($x)$., corresponding to the following two formats: Eric Allman <[email protected]> [email protected] (Eric Allman) Sendmail properly quotes names that have special characters if the rst form is used.
17
$f $g $h $i $j
$k $l
$m $n $o
$p $q
As of version 8.6, all of these macros have reasonable defaults. Previous versions required that they be dened.
SMM:08-40
$r $s $t $u $v $x $z $_
Protocol used to receive the message. Set from the p command line ag or by the SMTP server code. Senders host name. Set from the p command line ag or by the SMTP server code. A numeric representation of the current time. The recipient user. The version number of the sendmail binary. The full name of the sender. The home directory of the recipient. The validated sender address.
$w The hostname of this site. This is the root name of this host (but see below for caveats).
${auth_authen} The clients authentication credentials as determined by authentication (only set if successful). ${auth_author} The authorization identity, i.e. the AUTH= parameter of the SMTP MAIL command if supplied. ${auth_type} The mechanism used for authentication (only set if successful). ${auth_ssf} The keylength (in bits) of the symmetric encryption algorithm used for the security layer of a SASL mechanism. ${bodytype} The message body type (7BIT or 8BITMIME), as determined from the envelope. ${cert_issuer} The DN (distinguished name) of the CA (certicate authority) that signed the presented certicate (the cert issuer). ${cert_subject} The DN of the presented certicate (called the cert subject). ${cipher} The cipher suite used for the connection, e.g., EDH-DSS-DES-CBC3-SHA, EDH-RSA-DESCBC-SHA, DES-CBC-MD5, DES-CBC3-SHA. ${cipher_bits} The keylength (in bits) of the symmetric encryption algorithm used for a TLS connection. ${client_addr} The IP address of the SMTP client. Dened in the SMTP server only. ${client_name} The host name of the SMTP client. This may be the clients bracketed IP address in the form [ nnn.nnn.nnn.nnn ] if the clients IP address is not resolvable, or if it is resolvable but the IP address of the resolved hostname doesnt match the original IP address. Dened in the SMTP server only. ${client_port} The port number of the SMTP client. Dened in the SMTP server only. ${client_resolve} Holds the result of the resolve call for ${client_name} : OK, FAIL, FORGED, TEMP. Dened in the SMTP server only.
SMM:08-41
${currHeader} Header value as quoted string (possibly truncated to MAXNAME). ${daemon_addr} The IP address the daemon is listening on for connections. Unless DaemonPortOptions is set, this will be 0.0.0.0. ${daemon_family} The network family if the daemon is accepting network connections. Possible values include inet, inet6, iso, ns, x.25 ${daemon_ags} The ags for the daemon as specied by the Modier= part of DaemonPortOptions whereby the ags are separated from each other by spaces, and upper case ags are doubled. That is, Modier=Ea will be represented as "EE a" in ${daemon_ags}, which is required for testing the ags in rulesets. ${daemon_info} Some information about a daemon as a text string. For example, SMTP+queueing@00:30:00. ${daemon_name} The name of the daemon from DaemonPortOptions Name= suboption. If this suboption is not set, "Daemon#", where # is the daemon number, is used. ${daemon_port} The port the daemon is accepting connection on. Unless DaemonPortOptions is set, this will most likely be 25. ${deliveryMode} The current delivery mode sendmail is using. It is initially set to the value of the DeliveryMode option. ${envid} The envelope id passed to sendmail as part of the envelope. ${hdrlen} The length of the header value which is stored in ${currHeader} (before possible truncation). If this value is greater than or equal MAXNAME the header has been truncated. ${hdr_name} The name of the header eld for which the current header check ruleset has been called. This is useful for a default header check ruleset to get the name of the header. ${if_addr} The IP address of the interface of an incoming connection unless it is in the loopback net. ${if_family} The IP family of the interface of an incoming connection unless it is in the loopback net. ${if_name} The name of the interface of an incoming connection. This macro can be used for SmtpGreetingMessage and HReceived for virtual hosting. For example: O SmtpGreetingMessage=$?{if_name}${if_name}$|$j$. MTA ${mail_addr} The address part of the resolved triple of the address given for the SMTP MAIL command. Dened in the SMTP server only. ${mail_host} The host from the resolved triple of the address given for the SMTP MAIL command. Dened in the SMTP server only.
SMM:08-42
${mail_mailer} The mailer from the resolved triple of the address given for the SMTP MAIL command. Dened in the SMTP server only. ${msg_size} The value of the SIZE= parameter, i.e., usually the size of the message (in an ESMTP dialogue), before the message has been collected, thereafter the message size as computed by sendmail (and can be used in check_compat). ${ntries} The number of delivery attempts. ${opMode} The current operation mode (from the b ag). ${queue_interval} The queue run interval given by the q ag. For example, q30m would set ${queue_interval} to 00:30:00. ${rcpt_addr} The address part of the resolved triple of the address given for the SMTP RCPT command. Dened in the SMTP server only. ${rcpt_host} The host from the resolved triple of the address given for the SMTP RCPT command. Dened in the SMTP server only. ${rcpt_mailer} The mailer from the resolved triple of the address given for the SMTP RCPT command. Dened in the SMTP server only. ${server_addr} The address of the server of the current outgoing SMTP connection. ${server_name} The name of the server of the current outgoing SMTP connection. ${tls_version} The TLS/SSL version used for the connection, e.g., TLSv1, SSLv3, SSLv2. ${verify} The result of the verication of the presented cert. Possible values are: verication succeeded. no cert presented. cert presented but could not be veried, e.g., the signing CA is missing. NONE STARTTLS has not been performed. TEMP temporary error occurred. PROTOCOL some protocol error occurred. SOFTWARE STARTTLS handshake failed, which is a fatal error for this session, the e-mail will be queued. There are three types of dates that can be used. The $a and $b macros are in RFC 822 format; $a is the time as extracted from the Date: line of the message (if there was one), and $b is the current date and time (used for postmarks). If no Date: line is found in the incoming message, $a is set to the current time also. The $d macro is equivalent to the $b macro in UNIX (ctime) format. The macros $w, $j, and $m are set to the identity of this host. Sendmail tries to nd the fully qualied name of the host if at all possible; it does this by calling gethostname(2) to get the current OK NO FAIL
SMM:08-43
hostname and then passing that to gethostbyname(3) which is supposed to return the canonical version of that host name.18 Assuming this is successful, $j is set to the fully qualied name and $m is set to the domain part of the name (everything after the rst dot). The $w macro is set to the rst word (everything before the rst dot) if you have a level 5 or higher conguration le; otherwise, it is set to the same value as $j. If the canonication is not successful, it is imperative that the cong le set $j to the fully qualied domain name19. The $f macro is the id of the sender as originally determined; when mailing to a specic host the $g macro is set to the address of the sender relative to the recipient. For example, if I send to [email protected] from the machine vangogh.CS.Berkeley.EDU the $f macro will be eric and the $g macro will be [email protected]. The $x macro is set to the full name of the sender. This can be determined in several ways. It can be passed as ag to sendmail. It can be dened in the NAME environment variable. The third choice is the value of the Full-Name: line in the header if it exists, and the fourth choice is the comment eld of a From: line. If all of these fail, and if the message is being originated locally, the full name is looked up in the /etc/passwd le. When sending, the $h, $u, and $z macros get set to the host, user, and home directory (if local) of the recipient. The rst two are set from the $@ and $: part of the rewriting rules, respectively. The $p and $t macros are used to create unique strings (e.g., for the Message-Id: eld). The $i macro is set to the queue id on this host; if put into the timestamp line it can be extremely useful for tracking messages. The $v macro is set to be the version number of sendmail; this is normally put in timestamps and has been proven extremely useful for debugging. The $c eld is set to the hop count, i.e., the number of times this message has been processed. This can be determined by the h ag on the command line or by counting the timestamps in the message. The $r and $s elds are set to the protocol used to communicate with sendmail and the sending hostname. They can be set together using the p command line ag or separately using the M or oM ags. The $_ is set to a validated sender host name. If the sender is running an RFC 1413 compliant IDENT server and the receiver has the IDENT protocol turned on, it will include the user name on that host. The ${client_name}, ${client_addr}, and ${client_port} macros are set to the name, address, and port number of the SMTP client who is invoking sendmail as a server. These can be used in the check_* rulesets (using the $& deferred evaluation form, of course!). 5.3. C and F Dene Classes Classes of phrases may be dened to match on the left hand side of rewriting rules, where a phrase is a sequence of characters that does not contain space characters. For example a class of all local names for this site might be created so that attempts to send to oneself can be eliminated. These can either be dened directly in the conguration le or read in from another le. Classes are named as a single letter or a word in {braces}. Class names beginning with lower case letters and special characters are reserved for system use. Classes dened in cong les may be given names from the set of upper case letters for short names or beginning with an upper case letter for long names.
18 19
For example, on some systems gethostname might return foo which would be mapped to foo.bar.com by gethostbyname.
Older versions of sendmail didnt pre-dene $j at all, so up until 8.6, cong les always had to dene $j.
SMM:08-44
The syntax is: Cc phrase1 phrase2... Fc le Fc |program The rst form denes the class c to match any of the named words. If phrase1 or phrase2 is another class, e.g., $=S, the contents of class S are added to class c. It is permissible to split them among multiple lines; for example, the two forms: CHmonet ucbmonet and CHmonet CHucbmonet are equivalent. The F forms read the elements of the class c from the named le or program. Each element should be listed on a separate line. To specify an optional le, use -o between the class name and the le name, e.g., Fc -o /path/to/le If the le cant be used, sendmail will not complain but silently ignore it. Elements of classes can be accessed in rules using $= or $. The $ (match entries not in class) only matches a single word; multi-word entries in the class are ignored in this context. Some classes have internal meaning to sendmail: $=e $=k $=m $=n contains the Content-Transfer-Encodings that can be 87 bit encoded. It is predened to contain 7bit, 8bit, and binary. set to be the same as $k, that is, the UUCP node name. set to the set of domains by which this host is known, initially just $m. can be set to the set of MIME body types that can never be eight to seven bit encoded. It defaults to multipart/signed. Message types message/* and multipart/* are never encoded directly. Multipart messages are always handled recursively. The handling of message/* messages are controlled by class $=s. A set of Content-Types that will never be encoded as base64 (if they have to be encoded, they will be encoded as quoted-printable). It can have primary types (e.g., text) or full types (such as text/plain). The class is initialized to have text/plain only. contains the set of subtypes of message that can be treated recursively. By default it contains only rfc822. Other message/* types cannot be 87 bit encoded. If a message containing eight bit data is sent to a seven bit host, and that message cannot be encoded into seven bits, it will be stripped to 7 bits. set to the set of trusted users by the T conguration line. If you want to read trusted users from a le, use Ft/le/name. set to be the set of all names this host is known by. This can be used to match local hostnames.
$=q
$=s
$=t $=w
$={persistentMacros} set to the macros would should be saved across queue runs. Care should be taken when adding macro names to this class. Sendmail can be compiled to allow a scanf(3) string on the F line. This lets you do simplistic parsing of text les. For example, to read all the user names in your system /etc/passwd le into a class, use FL/etc/passwd %[:]
SMM:08-45
which reads every line up to the rst colon. 5.4. M Dene Mailer Programs and interfaces to mailers are dened in this line. The format is: Mname, {eld=value }* where name is the name of the mailer (used internally only) and the eld=name pairs dene attributes of the mailer. Fields are: Path Flags Sender Recipient Argv Eol Maxsize maxmessages Linelimit Directory Userid Nice Charset Type Wait / The pathname of the mailer Special ags for this mailer Rewriting set(s) for sender addresses Rewriting set(s) for recipient addresses An argument vector to pass to this mailer The end-of-line string for this mailer The maximum message length to this mailer The maximum message deliveries per connection The maximum line length in the message body The working directory for the mailer The default user and group id to run as The nice(2) increment for the mailer The default character set for 8-bit characters Type information for DSN diagnostics The maximum time to wait for the mailer The root directory for the mailer
Only the rst character of the eld name is checked. The following ags may be set in the mailer description. Any other ags may be used freely to conditionally assign headers to messages destined for particular mailers. Flags marked with are not interpreted by the sendmail binary; these are the conventionally used to correlate to the ags portion of the H line. Flags marked with apply to the mailers for the sender address rather than the usual recipient mailers. a A b Run Extended SMTP (ESMTP) protocol (dened in RFCs 1869, 1652, and 1870). This ag defaults on if the SMTP greeting message includes the word ESMTP. Look up the user part of the address in the alias database. Normally this is only set for local mailers. Force a blank line on the end of a message. This is intended to work around some stupid versions of /bin/mail that require a blank line, but do not provide it themselves. It would not normally be used on network mail. Do not include comments in addresses. This should only be used if you have to work around a remote mailer that gets confused by comments. This strips addresses of the form Phrase <address> or address (Comment) down to just address.
C If mail is received from a mailer with this ag set, any addresses in the header that do not have an at sign (@) after being rewritten by ruleset three will have the @domain clause from the sender envelope address tacked on. This allows mail with headers of the form: From: usera@hosta To: userb@hostb, userc to be rewritten as: From: usera@hosta To: userb@hostb, userc@hosta automatically. However, it doesnt really work reliably.
SMM:08-46
Do not include angle brackets around route-address syntax addresses. This is useful on mailers that are going to pass addresses to a shell that might interpret angle brackets as I/O redirection. However, it does not protect against other shell metacharacters. Therefore, passing addresses to a shell should not be considered secure. This mailer is expensive to connect to, so try to avoid connecting normally; any necessary connection will occur during a queue run. See also option HoldExpensive. Escape lines beginning with From in the message with a > sign. The mailer wants a f from ag, but only if this is a network forward operation (i.e., the mailer will give an error if the executing user does not have special permissions). Normally, sendmail sends internally generated email (e.g., error messages) using the null return address as required by RFC 1123. However, some mailers dont accept a null return address. If necessary, you can set the g ag to prevent sendmail from obeying the standards; error messages will be sent as from the MAILER-DAEMON (actually, the value of the $n macro). Upper case should be preserved in host names (the $@ portion of the mailer triplet resolved from ruleset 0) for this mailer. Do User Database rewriting on envelope sender address. This mailer will be speaking SMTP to another sendmail as such it can use special protocol features. This option is not required (i.e., if this option is omitted the transmission will still operate successfully, although perhaps not as efciently as possible). Do User Database rewriting on recipients as well as senders. Normally when sendmail connects to a host via SMTP, it checks to make sure that this isnt accidently the same host name as might happen if sendmail is miscongured or if a long-haul network interface is set in loopback mode. This ag disables the loopback check. It should only be used under very unusual circumstances. Currently unimplemented. Reserved for chunking. This mailer is local (i.e., nal delivery will be performed). Limit the line lengths as specied in RFC821. This deprecated option should be replaced by the L= mail declaration. For historic reasons, the L ag also sets the 7 ag. This mailer can send to multiple users on the same host in one transaction. When a $u macro occurs in the argv part of the mailer denition, that eld will be repeated as necessary for all qualifying users. Removing this ag can defeat duplicate supression on a remote site as each recipient is sent in a separate transaction. Do not insert a UNIX-style From line on the front of the message. Always run as the owner of the recipient mailbox. Normally sendmail runs as the sender for locally generated mail or as daemon (actually, the user specied in the u option) when delivering network mail. The normal behavior is required by most local mailers, which will not allow the envelope sender address to be set unless the mailer is running as daemon. This ag is ignored if the S ag is set. Use the route-addr style reverse-path in the SMTP MAIL FROM: command rather than just the return address; although this is required in RFC821 section 3.1, many hosts do not process reverse-paths properly. Reverse-paths are ofcially discouraged by RFC 1123.
h i I
j k
K l L m
SMM:08-47
P This mailer wants a Return-Path: line. q r R s S When an address that resolves to this mailer is veried (SMTP VRFY command), generate 250 responses instead of 252 responses. This will imply that the address is local. Same as f, but sends a r ag. Open SMTP connections from a secure port. Secure ports arent (secure, that is) except on UNIX machines, so it is unclear that this adds anything. Strip quote characters (" and \) off of the address before calling the mailer. Dont reset the userid before calling the mailer. This would be used in a secure environment where sendmail ran as root. This could be used to avoid forged addresses. If the U= eld is also specied, this ag causes the effective user id to be set to that user. Upper case should be preserved in user names for this mailer. Standards require preservation of case in the local part of addresses, except for those address for which your system accepts responsibility. This mailer wants UUCP-style From lines with the ugly remote from <host> on the end. The user must have a valid account on this machine, i.e., getpwnam must succeed. If not, the mail is bounced. This is required to get .forward capability. This mailer wants a Full-Name: header line. This mailer want to use the hidden dot algorithm as specied in RFC821; basically, any line beginning with a dot will have an extra dot prepended (to be stripped at the other end). This insures that lines in the message containing a dot will not terminate the message prematurely. Run Local Mail Transfer Protocol (LMTP) between sendmail and the local mailer. This is a variant on SMTP dened in RFC 2033 that is specically designed for delivery to a local mailbox. Dont look up MX records for hosts sent via SMTP. Extend the list of characters converted to =XX notation when converting to Quoted-Printable to include those that dont map cleanly between ASCII and EBCDIC. Useful if you have IBM mainframes on site. If no aliases are found for this address, pass the address through ruleset 5 for possible alternate resolution. This is intended to forward the mail to an alternate delivery spot. Strip headers to seven bits. Strip all output to seven bits. This is the default if the L ag is set. Note that clearing this option is not sufcient to get full eight bit data passed through sendmail. If the 7 option is set, this is essentially always set, since the eighth bit was stripped on input. Note that this option will only impact messages that didnt have 87 bit MIME conversions performed. If set, it is acceptable to send eight bit data to this mailer; the usual attempt to do 87 bit MIME conversions will be bypassed. If set, do limited 78 bit MIME conversions. These conversions are limited to text/plain data. Check addresses to see if they begin :include:; if they do, convert them to the *include* mailer. Check addresses to see if they begin with a |; if they do, convert them to the prog mailer. Check addresses to see if they begin with a /; if they do, convert them to the *le* mailer. Look up addresses in the user database. Do not attempt delivery on initial recipient of a message or on queue runs unless the queued message is selected using one of the -qI/-qR/-qS queue run modiers or an ETRN request.
U w x X
0 3
5 6 7
8 9 : | / @ %
SMM:08-48
Conguration les prior to level 6 assume the A, w, 5, :, |, /, and @ options on the mailer named local. The mailer with the special name error can be used to generate a user error. The (optional) host eld is an exit status to be returned, and the user eld is a message to be printed. The exit status may be numeric or one of the values USAGE, NOUSER, NOHOST, UNAVAILABLE, SOFTWARE, TEMPFAIL, PROTOCOL, or CONFIG to return the corresponding EX_ exit code, or an enhanced error code as described in RFC 1893, Enhanced Mail System Status Codes. For example, the entry: $#error $@ NOHOST $: Host unknown in this domain on the RHS of a rule will cause the specied error to be generated and the Host unknown exit status to be returned if the LHS matches. This mailer is only functional in rulesets 0, 5, or one of the check_* rulesets. The mailer with the special name discard causes any mail sent to it to be discarded but otherwise treated as though it were successfully delivered. This mailer can not be used in ruleset 0, only in the various address checking rulesets. The mailer named local must be dened in every conguration le. This is used to deliver local mail, and is treated specially in several ways. Additionally, three other mailers named prog, *le*, and *include* may be dened to tune the delivery of messages to programs, les, and :include: lists respectively. They default to: Mprog, P=/bin/sh, F=lsoDq9, T=DNS/RFC822/X-Unix, A=sh c $u M*le*, P=[FILE], F=lsDFMPEouq9, T=DNS/RFC822/X-Unix, A=FILE $u M*include*, P=/dev/null, F=su, A=INCLUDE $u The Sender and Recipient rewriting sets may either be a simple ruleset id or may be two ids separated by a slash; if so, the rst rewriting set is applied to envelope addresses and the second is applied to headers. Setting any value zero disables corresponding mailer-specic rewriting. The Directory is actually a colon-separated path of directories to try. For example, the denition D=$z:/ rst tries to execute in the recipients home directory; if that is not available, it tries to execute in the root of the lesystem. This is intended to be used only on the prog mailer, since some shells (such as csh) refuse to execute if they cannot read the home directory. Since the queue directory is not normally readable by unprivileged users csh scripts as recipients can fail. The Userid species the default user and group id to run as, overriding the DefaultUser option (q.v.). If the S mailer ag is also specied, this user and group will be set as the effective uid and gid for the process. This may be given as user:group to set both the user and group id; either may be an integer or a symbolic name to be looked up in the passwd and group les respectively. If only a symbolic user name is specied, the group id in the passwd le for that user is used as the group id. The Charset eld is used when converting a message to MIME; this is the character set used in the Content-Type: header. If this is not set, the DefaultCharset option is used, and if that is not set, the value unknown-8bit is used. WARNING: this eld applies to the senders mailer, not the recipients mailer. For example, if the envelope sender address lists an address on the local network and the recipient is on an external network, the character set will be set from the Charset= eld for the local network mailer, not that of the external network mailer. The Type= eld sets the type information used in MIME error messages as dened by RFC 1894. It is actually three values separated by slashes: the MTA-type (that is, the description of how hosts are named), the address type (the description of e-mail addresses), and the diagnostic type (the description of error diagnostic codes). Each of these must be a registered value or begin with X. The default is dns/rfc822/smtp.
SMM:08-49
The m= eld species the maximum number of messages to attempt to deliver on a single SMTP or LMTP connection. The /= eld species a new root directory for the mailer. The path is macro expanded and then passed to the chroot system call. The root directory is changed before the Directory eld is consulted or the uid is changed. The Wait= eld species the maximum time to wait for the mailer to return after sending all data to it. This applies to mailers that have been forked by sendmail. 5.5. H Dene Header The format of the header lines that sendmail inserts into the message are dened by the H line. The syntax of this line is one of the following: Hhname: htemplate H[?mags?]hname: htemplate H[?${macro}?]hname: htemplate Continuation lines in this spec are reected directly into the outgoing message. The htemplate is macro-expanded before insertion into the message. If the mags (surrounded by question marks) are specied, at least one of the specied ags must be stated in the mailer denition for this header to be automatically output. If a ${macro} (surrounded by question marks) is specied, the header will be automatically output if the macro is set. The macro may be set using any of the normal methods, including using the macro storage map in a ruleset. If one of these headers is in the input it is reected to the output regardless of these ags or macros. Some headers have special semantics that will be described later. A secondary syntax allows validation of headers as they are being read. To enable validation, use: HHeader: $>Ruleset HHeader: $>+Ruleset The indicated Ruleset is called for the specied Header, and can return $#error to reject the message or $#discard to discard the message (as with the other check_* rulesets). The ruleset receives the header eld-body as argument, i.e., not the header eld-name; see also ${hdr_name} and ${currHeader}. The header is treated as a structured eld, that is, comments (in parentheses) are deleted before processing, unless the second form $>+ is used. Note: only one ruleset can be associated with a header; sendmail will silently ignore multiple entries. For example, the conguration lines: HMessage-Id: $>CheckMessageId SCheckMessageId R< $+ @ $+ > $@ OK R$* $#error $: Illegal Message-Id header would refuse any message that had a Message-Id: header of any of the following forms: Message-Id: <> Message-Id: some text Message-Id: <legal text@domain> extra crud A default ruleset that is called for headers which dont have a specic ruleset dened for them can be specied by: H*: $>Ruleset or
SMM:08-50
H*: $>+Ruleset 5.6. O Set Option There are a number of global options that can be set from a conguration le. Options are represented by full words; some are also representable as single characters for back compatibility. The syntax of this line is: O option=value This sets option option to be value. Note that there must be a space between the letter O and the name of the option. An older version is: Oo value where the option o is a single character. Depending on the option, value may be a string, an integer, a boolean (with legal values t, T, f, or F; the default is TRUE), or a time interval. The options supported (with the old, one character names in brackets) are: AliasFile=spec, spec, ... [A] Specify possible alias le(s). Each spec should be in the format class: info where class: is optional and defaults to implicit. Depending on how sendmail is compiled, valid classes are implicit (search through a compiled-in list of alias le types, for back compatibility), hash (if NEWDB is specied), btree (if NEWDB is specied), dbm (if NDBM is specied), stab (internal symbol table not normally used unless you have no other database lookup), sequence (use a sequence of maps previously declared), ldap (if LDAPMAP is specied), or nis (if NIS is specied). If a list of specs are provided, sendmail searches them in order. AliasWait=timeout [a] If set, wait up to timeout (units default to minutes) for an @:@ entry to exist in the alias database before starting up. If it does not appear in the timeout interval rebuild the database (if the AutoRebuildAliases option is also set) or issue a warning. AllowBogusHELO [no short name] If set, allow HELO SMTP commands that dont include a host name. Setting this violates RFC 1123 section 5.2.5, but is necessary to interoperate with several SMTP clients. If there is a value, it is still checked for legitimacy. AuthMechanisms [no short name] List of authentication mechanisms for AUTH (separated by spaces). The advertised list of authentication mechanisms will be the intersection of this list and the list of available mechanisms as determined by the Cyrus SASL library. AuthOptions [no short name] When to use the AUTH= parameter for the MAIL FROM command; A Only when authentication succeeded. The default is to try whenever SMTP AUTH is available. AutoRebuildAliases [D] If set, rebuild the alias database if necessary and possible. The rebuild will happen the next time an alias is looked up. If this option is not set, sendmail will never rebuild the alias database unless explicitly requested using bi. NOTE: There is a potential for a denial of service attack if this is set. This option is deprecated and will be removed from a future version.
SMM:08-51
[B] Set the blank substitution character to c. Unquoted spaces in addresses are replaced by this character. Defaults to space (i.e., no change is made). [no short name] Path to directory with certicates of CAs. [no short name] File containing one CA certicate. [n] Validate the RHS of aliases when rebuilding the alias database.
CheckpointInterval=N [C] Checkpoints the queue every N (default 10) addresses sent. If your system crashes during delivery to a large list, this prevents retransmission to any but the last N recipients. ClassFactor=fact [z] The indicated factor is multiplied by the message class (determined by the Precedence: eld in the user header and the P lines in the conguration le) and subtracted from the priority. Thus, messages with a higher Priority: will be favored. Defaults to 1800. ClientCertFile [no short name] File containing the certicate of the client, i.e., this certicate is used when sendmail acts as client.
ClientPortOptions=options [O] Set client SMTP options. The options are key=value pairs separated by commas. Known keys are: Port Addr Family SndBufSize RcvBufSize Modier Name/number of source port for connection (defaults to any free port) Address mask (defaults INADDR_ANY) Address family (defaults to INET) Size of TCP send buffer Size of TCP receive buffer Options (ags) for the daemon
The Address mask may be a numeric address in dot notation or a network name. Modier can be the following character: h use name of interface for HELO command If h is set, the name corresponding to the outgoing interface address (whether chosen via the Connection parameter or the default) is used for the HELO/EHLO command. ClientKeyFile [no short name] File containing the private key belonging to the client certicate. ColonOkInAddr [no short name] If set, colons are acceptable in e-mail addresses (e.g., host:user). If not set, colons indicate the beginning of a RFC 822 group construct (groupname: member1, member2, ... memberN;). Doubled colons are always acceptable (nodename::user) and proper route-addr nesting is understood (<@relay:user@host>). Furthermore, this option defaults on if the conguration version level is less than 6 (for back compatibility). However, it must be off for full compatibility with RFC 822. ConnectionCacheSize=N [k] The maximum number of open connections that will be cached at a time. The default is one. This delays closing the current connection until either this invocation of sendmail needs to connect to another host or it terminates. Setting it to zero defaults to the old behavior, that is, connections are closed immediately. Since this consumes le descriptors, the connection cache should be kept small: 4 is probably a practical maximum. ConnectionCacheTimeout=timeout [K] The maximum amount of time a cached connection will be permitted to idle without activity. If this time is exceeded, the connection is immediately closed.
SMM:08-52
This value should be small (on the order of ten minutes). Before sendmail uses a cached connection, it always sends a RSET command to check the connection; if this fails, it reopens the connection. This keeps your end from failing if the other end times out. The point of this option is to be a good network neighbor and avoid using up excessive resources on the other end. The default is ve minutes. ConnectOnlyTo=address [no short name] This can be used to override the connection address (for testing purposes). ConnectionRateThrottle=N [no short name] If set to a positive value, allow no more than N incoming daemon connections in a one second period. This is intended to atten out peaks and allow the load average checking to cut in. Defaults to zero (no limits). ControlSocketName=name [no short name] Name of the control socket for daemon management. A running sendmail daemon can be controlled through this named socket. Available commands are: help, restart, shutdown, and status. The status command returns the current number of daemon children, the maximum number of daemon children, the free disk space (in blocks) of the queue directory, and the load average of the machine expressed as an integer. If not set, no control socket will be available. Solaris and pre-4.4BSD kernel users should see the note in sendmail/README . DHParameters File with DH parameters for STARTTLS. This is only required if DSA/DH is used.
DaemonPortOptions=options [O] Set server SMTP options. Each instance of DaemonPortOptions leads to an additional incoming socket. The options are key=value pairs. Known keys are: Name Port Addr Family Listen Modier SndBufSize RcvBufSize User-denable name for the daemon (defaults to "Daemon#") Name/number of listening port (defaults to "smtp") Address mask (defaults INADDR_ANY) Address family (defaults to INET) Size of listen queue (defaults to 10) Options (ags) for the daemon Size of TCP send buffer Size of TCP receive buffer
The Name eld is used for error messages and logging. The Address mask may be a numeric address in dot notation or a network name. The Family key defaults to INET (IPv4). IPv6 users who wish to also accept IPv6 connections should add additional Family=inet6 DaemonPortOptions lines. Modier can be a sequence (without any delimiters) of the following characters: a b c f u C E always require authentication bind to interface through which mail has been received perform hostname canonication (.cf) require fully qualied hostname (.cf) allow unqualied addresses (.cf) dont perform hostname canonication disallow ETRN (see RFC 2476)
That is, one way to specify a message submission agent (MSA) that always requires authentication is: O DaemonPortOptions=Name=MSA, Port=587, M=Ea The modiers that are marked with "(.cf)" have only effect in the standard
SMM:08-53
conguration le, in which they are available via ${daemon_ags}. The ags c and C can change the default for hostname canonication in the sendmail.cf le. See the relevant documentation for FEATURE(nocanonify). The modier f disallows addresses of the form user@host unless they are submitted directly. The ag u allows unqualied sender addresses. b forces sendmail to bind to the interface through which the e-mail has been received for the outgoing connection. WARNING: Use b only if outgoing mail can be routed through the incoming connections interface to its destination. No attempt is made to catch problems due to a misconguration of this parameter, use it only for virtual hosting where each virtual interface can connect to every possible location. This will also override possible settings via ClientPortOptions. Note, sendmail will listen on a new socket for each occurence of the DaemonPortOptions option in a conguration le. DefaultAuthInfo [no short name] Filename that contains default authentication information for outgoing connections. This le must contain the user id, the authorization id, the password (plain text), and the realm to use on separate lines and must be readable by root (or the trusted user) only. If no realm is specied, $j is used. DefaultCharSet=charset [no short name] When a message that has 8-bit characters but is not in MIME format is converted to MIME (see the EightBitMode option) a character set must be included in the Content-Type: header. This character set is normally set from the Charset= eld of the mailer descriptor. If that is not set, the value of this option is used. If this option is not set, the value unknown-8bit is used. DataFileBufferSize=threshold [no short name] Set the threshold, in bytes, before a memory-based queue data le becomes disk-based. The default is 4096 bytes. DeadLetterDrop=le [no short name] Denes the location of the system-wide dead.letter le, formerly hardcoded to /usr/tmp/dead.letter. If this option is not set (the default), sendmail will not attempt to save to a system-wide dead.letter le in the event it can not bounce the mail to the user or postmaster. Instead, it will rename the qf le as it has in the past when the dead.letter le could not be opened. DefaultUser=user:group [u] Set the default userid for mailers to user:group. If group is omitted and user is a user name (as opposed to a numeric user id) the default group listed in the /etc/passwd le for that user is used as the default group. Both user and group may be numeric. Mailers without the S ag in the mailer denition will run as this user. Defaults to 1:1. The value can also be given as a symbolic user name.20 DeliveryMode=x [d] Deliver in mode x. Legal modes are: i b q d Deliver interactively (synchronously) Deliver in background (asynchronously) Just queue the message (deliver during queue run) Defer delivery and all map lookups (deliver during queue run)
Defaults to b if no option is specied, i if it is specied but given no argument (i.e., Od is equivalent to Odi). The v command line ag sets this to i.
20
The old g option has been combined into the DefaultUser option.
SMM:08-54
DialDelay=sleeptime [no short name] Dial-on-demand network connections can see timeouts if a connection is opened before the call is set up. If this is set to an interval and a connection times out on the rst connection being attempted sendmail will sleep for this amount of time and try again. This should give your system time to establish the connection to your service provider. Units default to seconds, so DialDelay=5 uses a ve second delay. Defaults to zero (no retry). DontBlameSendmail=option,option,... [no short name] In order to avoid possible cracking attempts caused by world- and group-writable les and directories, sendmail does paranoid checking when opening most of its support les. If for some reason you absolutely must run with, for example, a group-writable /etc directory, then you will have to turn off this checking (at the cost of making your system more vulnerable to attack). The arguments are individual options that turn off checking: Safe AssumeSafeChown ClassFileInUnsafeDirPath DontWarnForwardFileInUnsafeDirPath ErrorHeaderInUnsafeDirPath FileDeliveryToHardLink FileDeliveryToSymLink ForwardFileInUnsafeDirPath ForwardFileInUnsafeDirPathSafe ForwardFileIngroupWritableDirPath GroupWritableAliasFile GroupWritableDirPathSafe GroupWritableForwardFileSafe GroupWritableIncludeFileSafe HelpFileinUnsafeDirPath IncludeFileInUnsafeDirPath IncludeFileInUnsafeDirPathSafe IncludeFileIngroupWritableDirPath InsufcientEntropy LinkedAliasFileInWritableDir LinkedClassFileInWritableDir LinkedForwardFileInWritableDir LinkedIncludeFileInWritableDir LinkedMapInWritableDir LinkedServiceSwitchFileInWritableDir MapInUnsafeDirPath NonRootSafeAddr RunProgramInUnsafeDirPath RunWritableProgram TrustStickyBit WorldWritableAliasFile WriteMapToHardLink WriteMapToSymLink WriteStatsToHardLink WriteStatsToSymLink Safe is the default. The details of these ags are described above. Use of this option is not recommended.
SMM:08-55
DontExpandCnames [no short name] The standards say that all host addresses used in a mail message must be fully canonical. For example, if your host is named Cruft.Foo.ORG and also has an alias of FTP.Foo.ORG, the former name must be used at all times. This is enforced during host name canonication ($[ ... $] lookups). If this option is set, the protocols are ignored and the wrong thing is done. However, the IETF is moving toward changing this standard, so the behavior may become acceptable. Please note that hosts downstream may still rewrite the address to be the true canonical name however. DontInitGroups [no short name] If set, sendmail will avoid using the initgroups(3) call. If you are running NIS, this causes a sequential scan of the groups.byname map, which can cause your NIS server to be badly overloaded in a large domain. The cost of this is that the only group found for users will be their primary group (the one in the password le), which will make le access permissions somewhat more restrictive. Has no effect on systems that dont have group lists. DontProbeInterfaces [no short name] Sendmail normally nds the names of all interfaces active on your machine when it starts up and adds their name to the $=w class of known host aliases. If you have a large number of virtual interfaces or if your DNS inverse lookups are slow this can be time consuming. This option turns off that probing. However, you will need to be certain to include all variant names in the $=w class by some other mechanism. DontPruneRoutes [R] Normally, sendmail tries to eliminate any unnecessary explicit routes when sending an error message (as discussed in RFC 1123 5.2.6). For example, when sending an error message to <@known1,@known2,@known3:user@unknown> sendmail will strip off the @known1,@known2 in order to make the route as direct as possible. However, if the R option is set, this will be disabled, and the mail will be sent to the rst address in the route, even if later addresses are known. This may be useful if you are caught behind a rewall. DoubleBounceAddress=error-address [no short name] If an error occurs when sending an error message, send the error report (termed a double bounce because it is an error bounce that occurs when trying to send another error bounce) to the indicated address. The address is macro expanded at the time of delivery. If not set, defaults to postmaster. EightBitMode=action [8] Set handling of eight-bit data. There are two kinds of eight-bit data: that declared as such using the BODY=8BITMIME ESMTP declaration or the B8BITMIME command line ag, and undeclared 8-bit data, that is, input that just happens to be eight bits. There are three basic operations that can happen: undeclared 8-bit data can be automatically converted to 8BITMIME, undeclared 8-bit data can be passed as-is without conversion to MIME (just send 8), and declared 8-bit data can be converted to 7-bits for transmission to a non-8BITMIME mailer. The possible actions are: s Reject undeclared 8-bit data (strict) m Convert undeclared 8-bit data to MIME (mime) p Pass undeclared 8-bit data (pass) In all cases properly declared 8BITMIME data will be converted to 7BIT as needed.
SMM:08-56
ErrorHeader=le-or-message [E] Prepend error messages with the indicated message. If it begins with a slash, it is assumed to be the pathname of a le containing a message (this is the recommended setting). Otherwise, it is a literal message. The error le might contain the name, email address, and/or phone number of a local postmaster who could provide assistance to end users. If the option is missing or null, or if it names a le which does not exist or which is not readable, no message is printed. ErrorMode=x [e] Dispose of errors using mode x. The values for x are: p q m w e Print error messages (default) No messages, just give exit status Mail back errors Write back errors (mail if user not logged in) Mail back errors and give zero exit stat always
FallbackMXhost=fallbackhost [V] If specied, the fallbackhost acts like a very low priority MX on every host. This is intended to be used by sites with poor network connectivity. Messages which are undeliverable due to temporary address failures (e.g., DNS failure) also go to the FallBackMX host. ForkEachJob [Y] If set, deliver each job that is run from the queue in a separate process. Use this option if you are short of memory, since the default tends to consume considerable amounts of memory while the queue is being processed.
ForwardPath=path [J] Set the path for searching for users .forward les. The default is $z/.forward. Some sites that use the automounter may prefer to change this to /var/forward/$u to search a le with the same name as the user in a system directory. It can also be set to a sequence of paths separated by colons; sendmail stops at the rst le it can successfully and safely open. For example, /var/forward/$u:$z/.forward will search rst in /var/forward/username and then in username/.forward (but only if the rst le does not exist). HelpFile=le HoldExpensive [H] Specify the help le for SMTP. If no le name is specied, "helple" is used. [c] If an outgoing mailer is marked as being expensive, dont connect immediately. This requires that queueing be compiled in, since it will depend on a queue run process to actually send the mail. [no short name] The path to the hosts database, normally /etc/hosts. This option is only consulted when sendmail is canonifying addresses, and then only when les is in the hosts service switch entry. In particular, this le is never used when looking up host addresses; that is under the control of the system gethostbyname(3) routine.
HostsFile=path
HostStatusDirectory=path [no short name] The location of the long term host status information. When set, information about the status of hosts (e.g., host down or not accepting connections) will be shared between all sendmail processes; normally, this information is only held within a single queue run. This option requires a connection cache of at least 1 to function. If the option begins with a leading /, it is an absolute pathname; otherwise, it is relative to the mail queue directory. A suggested value for sites desiring persistent host status is .hoststat (i.e., a subdirectory of the queue directory). IgnoreDots [i] Ignore dots in incoming messages. This is always disabled (that is, dots are always accepted) when reading SMTP mail.
SMM:08-57
LDAPDefaultSpec=spec [no short name] Sets a default map specication for LDAP maps. The value should only contain LDAP specic settings such as -h host -p port -d bindDN. The settings will be used for all LDAP maps unless the individual map specication overrides a setting. This option should be set before any LDAP maps are dened. LogLevel=n Mx value MatchGECOS [L] Set the log level to n. Defaults to 9. [no long version] Set the macro x to value. This is intended only for use from the command line. The M ag is preferred. [G] Allow fuzzy matching on the GECOS eld. If this ag is set, and the usual user name lookups fail (that is, there is no alias with this name and a getpwnam fails), sequentially search the password le for a matching entry in the GECOS eld. This also requires that MATCHGECOS be turned on during compilation. This option is not recommended.
MaxAliasRecursion=N [no short name] The maximum depth of alias recursion (default: 10). MaxDaemonChildren=N [no short name] If set, sendmail will refuse connections when it has more than N children processing incoming mail or automatic queue runs. This does not limit the number of outgoing connections. If not set, there is no limit to the number of children -- that is, the system load averaging controls this. MaxHeadersLength=N [no short name] The maximum length of the sum of all headers. This can be used to prevent a denial of service attack. The default is no limit. MaxHopCount=N [h] The maximum hop count. Messages that have been processed more than N times are assumed to be in a loop and are rejected. Defaults to 25. MaxMessageSize=N [no short name] Specify the maximum message size to be advertised in the ESMTP EHLO response. Messages larger than this will be rejected. MaxMimeHeaderLength=N[/M] [no short name] Sets the maximum length of certain MIME header eld values to N characters. For some of these headers which take parameters, the maximum length of each parameter is set to M if specied. If /M is not specied, one half of N will be used. By default, these values are 0, meaning no checks are done. MaxQueueRunSize=N [no short name] The maximum number of jobs that will be processed in a single queue run. If not set, there is no limit on the size. If you have very large queues or a very short queue run interval this could be unstable. However, since the rst N jobs in queue directory order are run (rather than the N highest priority jobs) this should be set as high as possible to avoid losing jobs that happen to fall late in the queue directory. MaxRecipientsPerMessage=N [no short name] The maximum number of recipients that will be accepted per message in an SMTP transaction. Note: setting this too low can interfere with sending mail from MUAs that use SMTP for initial submission. If not set, there is no limit on the number of recipients per envelope. MeToo [m] Send to me too, even if I am in an alias expansion. This option is deprecated and will be removed from a future version.
SMM:08-58
MinFreeBlocks=N [b] Insist on at least N blocks free on the lesystem that holds the queue les before accepting email via SMTP. If there is insufcient space sendmail gives a 452 response to the MAIL command. This invites the sender to try again later. MinQueueAge=age [no short name] Dont process any queued jobs that have been in the queue less than the indicated time interval. This is intended to allow you to get responsiveness by processing the queue fairly frequently without thrashing your system by trying jobs too often. The default units are minutes. MustQuoteChars=s [no short name] Sets the list of characters that must be quoted if used in a full name that is in the phrase part of a phrase <address> syntax. The default is .. The characters @,;:\()[] are always added to this list. NoRecipientAction [no short name] The action to take when you receive a message that has no valid recipient headers (To:, Cc:, Bcc:, or Apparently-To: the last included for back compatibility with old sendmails). It can be None to pass the message on unmodied, which violates the protocol, Add-To to add a To: header with any recipients it can nd in the envelope (which might expose Bcc: recipients), Add-Apparently-To to add an Apparently-To: header (this is only for back-compatibility and is ofcially deprecated), Add-To-Undisclosed to add a header To: undisclosedrecipients:; to make the header legal without disclosing anything, or Add-Bcc to add an empty Bcc: header. OldStyleHeaders [o] Assume that the headers may be in old format, i.e., spaces delimit names. This actually turns on an adaptive algorithm: if any recipient address contains a comma, parenthesis, or angle bracket, it will be assumed that commas already exist. If this ag is not on, only commas delimit names. Headers are always output with commas between the names. Defaults to off. OperatorChars=charlist [$o macro] The list of characters that are considered to be operators, that is, characters that delimit tokens. All operator characters are tokens by themselves; sequences of non-operator characters are also tokens. White space characters separate tokens but are not tokens themselves for example, AAA.BBB has three tokens, but AAA BBB has two. If not set, OperatorChars defaults to . : @ [ ]; additionally, the characters ( ) < > , ; are always operators. Note that OperatorChars must be set in the conguration le before any rulesets. PidFile=lename [no short name] Filename of the pid le. (default is _PATH_SENDMAILPID). The lename is macro-expanded before it is opened. PostmasterCopy=postmaster [P] If set, copies of error messages will be sent to the named postmaster. Only the header of the failed message is sent. Errors resulting from messages with a negative precedence will not be sent. Since most errors are user problems, this is probably not a good idea on large sites, and arguably contains all sorts of privacy violations, but it seems to be popular with certain operating systems vendors. The address is macro expanded at the time of delivery. Defaults to no postmaster copies. PrivacyOptions= opt,opt,... [p] Set the privacy options. Privacy is really a misnomer; many of these are just a way of insisting on stricter adherence to the SMTP protocol. The options can be selected from:
SMM:08-59
public needmailhelo needexpnhelo noexpn needvrfyhelo novrfy noetrn noverb restrictmailq restrictqrun noreceipts nobodyreturn goaway authwarnings
Allow open access Insist on HELO or EHLO command before MAIL Insist on HELO or EHLO command before EXPN Disallow EXPN entirely, implies noverb. Insist on HELO or EHLO command before VRFY Disallow VRFY entirely Disallow ETRN entirely Disallow VERB entirely Restrict mailq command Restrict q command line ag Dont return success DSNs21 Dont return the body of a message with DSNs Disallow essentially all SMTP status queries Put X-Authentication-Warning: headers in messages and log warnings
The goaway pseudo-ag sets all ags except noreceipts, restrictmailq, restrictqrun, noetrn, and nobodyreturn. If mailq is restricted, only people in the same group as the queue directory can print the queue. If queue runs are restricted, only root and the owner of the queue directory can run the queue. Authentication Warnings add warnings about various conditions that may indicate attempts to spoof the mail system, such as using an non-standard queue directory. ProcessTitlePrex=string [no short name] Prex the process title shown on ps listings with string. The string will be macro processed. QueueDirectory=dir [Q] Use the named dir as the queue directory. To use multiple queues, supply a value ending with an asterisk. For example, /var/spool/mqueue/q* will use all of the directories or symbolic links to directories beginning with q in /var/spool/mqueue as queue directories. Do not change the queue directory structure while sendmail is running. QueueFactor=factor [q] Use factor as the multiplier in the map function to decide when to just queue up jobs rather than run them. This value is divided by the difference between the current load average and the load average limit (QueueLA option) to determine the maximum message priority that will be sent. Defaults to 600000. QueueLA=LA [x] When the system load average exceeds LA, just queue messages (i.e., dont try to send them). Defaults to 8 multiplied by the number of processors online on the system (if that can be determined).
QueueSortOrder=algorithm [no short name] Sets the algorithm used for sorting the queue. Only the rst character of the value is used. Legal values are host (to order by the name of the rst host name of the rst recipient), lename (to order by the name of the queue le name), time (to order by the submission time), and priority (to order by message priority). Host ordering makes better use of the connection cache, but may tend to process low priority messages that go to a single host over high priority messages that go to several hosts; it probably shouldnt be used on slow network links. Filename ordering saves the overhead of reading all of the
21
N.B.: the noreceipts ag turns off support for RFC 1891 (Delivery Status Notication).
SMM:08-60
queued items before starting the queue run. Time ordering is almost always a bad idea, since it allows large, bulk mail to go out before smaller, personal mail, but may have applicability on some hosts with very fast connections. Priority ordering is the default. QueueTimeout=timeout [T] A synonym for Timeout.queuereturn. Use that form instead of the QueueTimeout form. RandFile [no short name] Name of le containing random data or the name of the UNIX socket if EGD is used. A (required) prex "egd:" or "le:" species the type. STARTTLS requires this lename if the compile ag HASURANDOMDEV is not set (see sendmail/README).
ResolverOptions=options [I] Set resolver options. Values can be set using +ag and cleared using ag; the ags can be debug, aaonly, usevc, primary, igntc, recurse, defnames, stayopen, or dnsrch. The string HasWildcardMX (without a + or ) can be specied to turn off matching against MX records when doing name canonications. N.B. Prior to 8.7, this option indicated that the name server be responding in order to accept addresses. This has been replaced by checking to see if the dns method is listed in the service switch entry for the hosts service. RrtImpliesDsn [R] If this option is set, a Return-Receipt-To: header causes the request of a DSN, which is sent to the envelope sender as required by RFC1891, not to the address given in the header.
RunAsUser=user [no short name] The user parameter may be a user name (looked up in /etc/passwd) or a numeric user id; either form can have :group attached (where group can be numeric or symbolic). If set to a non-zero (non-root) value, sendmail will change to this user id shortly after startup22. This avoids a certain class of security problems. However, this means that all .forward and :include: les must be readable by the indicated user and all les to be written must be writable by user Also, all le and program deliveries will be marked unsafe unless the option DontBlameSendmail=NonRootSafeAddr is set, in which case the delivery will be done as user. It is also incompatible with the SafeFileEnvironment option. In other words, it may not actually add much to security on an average system, and may in fact detract from security (because other le permissions must be loosened). However, it should be useful on rewalls and other places where users dont have accounts and the aliases le is well constrained. RecipientFactor=fact [y] The indicated factor is added to the priority (thus lowering the priority of the job) for each recipient, i.e., this value penalizes jobs with large numbers of recipients. Defaults to 30000. RefuseLA=LA [X] When the system load average exceeds LA, refuse incoming SMTP connections. Defaults to 12 multiplied by the number of processors online on the system (if that can be determined).
RetryFactor=fact [Z] The factor is added to the priority every time a job is processed. Thus, each time a job is processed, its priority will be decreased by the indicated value. In most environments this should be positive, since hosts that are down are all too often down for a long time. Defaults to 90000.
22
When running as a daemon, it changes to this user after accepting a connection but before reading any SMTP commands.
SMM:08-61
SafeFileEnvironment=dir [no short name] If this option is set, sendmail will do a chroot(2) call into the indicated directory before doing any le writes. If the le name specied by the user begins with dir, that partial path name will be stripped off before writing, so (for example) if the SafeFileEnvironment variable is set to /safe then aliases of /safe/logs/le and /logs/le actually indicate the same le. Additionally, if this option is set, sendmail refuses to deliver to symbolic links. SaveFromLine [f] Save UNIX-style From lines at the front of headers. Normally they are assumed redundant and discarded.
SendMimeErrors [j] If set, send error messages in MIME format (see RFC2045 and RFC1344 for details). If disabled, sendmail will not return the DSN keyword in response to an EHLO and will not do Delivery Status Notication processing as described in RFC1891. ServerCertFile ServerKeyFile [no short name] File containing the certicate of the server, i.e., this certicate is used when sendmail acts as server. [no short name] File containing the private key belonging to the server certicate.
ServiceSwitchFile=lename [no short name] If your host operating system has a service switch abstraction (e.g., /etc/nsswitch.conf on Solaris or /etc/svc.conf on Ultrix and DEC OSF/1) that service will be consulted and this option is ignored. Otherwise, this is the name of a le that provides the list of methods used to implement particular services. The syntax is a series of lines, each of which is a sequence of words. The rst word is the service name, and following words are service types. The services that sendmail consults directly are aliases and hosts. Service types can be dns, nis, nisplus, or les (with the caveat that the appropriate support must be compiled in before the service can be referenced). If ServiceSwitchFile is not specied, it defaults to /etc/mail/service.switch. If that le does not exist, the default switch is: aliases hosts SevenBitInput les dns nis les
The default le is /etc/mail/service.switch. [7] Strip input to seven bits for compatibility with old systems. This shouldnt be necessary.
SingleLineFromHeader [no short name] If set, From: lines that have embedded newlines are unwrapped onto one line. This is to get around a botch in Lotus Notes that apparently cannot understand legally wrapped RFC822 headers. SingleThreadDelivery [no short name] If set, a client machine will never try to open two SMTP connections to a single server machine at the same time, even in different processes. That is, if another sendmail is already talking to some host a new sendmail will not open another connection. This property is of mixed value; although this reduces the load on the other machine, it can cause mail to be delayed (for example, if one sendmail is delivering a huge message, other sendmails wont be able to send even small messages). Also, it requires another le descriptor (for the lock le) per connection, so you may have to reduce the ConnectionCacheSize option to avoid running out of per-process le descriptors. Requires the HostStatusDirectory option.
SMM:08-62
SmtpGreetingMessage=message [$e macro] The message printed when the SMTP server starts up. Defaults to $j Sendmail $v ready at $b. StatusFile=le [S] Log summary statistics in the named le. If no le name is specied, "statistics" is used. If not set, no summary statistics are saved. This le does not grow in size. It can be printed using the mailstats(8) program. [s] Be super-safe when running things, i.e., always instantiate the queue le, even if you are going to attempt immediate delivery. Sendmail always instantiates the queue le before returning control to the client under any circumstances. This should really always be set.
SuperSafe
TempFileMode=mode [F] The le mode for queue les. It is interpreted in octal by default. Defaults to 0600. Timeout.type= timeout [r; subsumes old T option as well] Set timeout values. For more information, see section 4.1. TimeZoneSpec=tzinfo [t] Set the local time zone info to tzinfo for example, PST8PDT. Actually, if this is not set, the TZ environment variable is cleared (so the system default is used); if set but null, the users TZ variable is used, and if set and non-null the TZ variable is set to this value. TrustedUser=user[no short name] The user parameter may be a user name (looked up in /etc/passwd) or a numeric user id. Trusted user for le ownership and starting the daemon. If set, generated alias databases and the control socket (if congured) will automatically be owned by this user. TryNullMXList [w] If this system is the best (that is, lowest preference) MX for a given host, its conguration rules should normally detect this situation and treat that condition specially by forwarding the mail to a UUCP feed, treating it as local, or whatever. However, in some cases (such as Internet rewalls) you may want to try to connect directly to that host as though it had no MX records at all. Setting this option causes sendmail to try this. The downside is that errors in your conguration are likely to be diagnosed as host unknown or message timed out instead of something more meaningful. This option is disrecommended. UnixFromLine=fromline [$l macro] Denes the format used when sendmail must add a UNIX-style From_ line (that is, a line beginning From<space>user). Defaults to From $g $d. Dont change this unless your system uses a different UNIX mailbox format (very unlikely). UnsafeGroupWrites [no short name] If set, :include: and .forward les that are group writable are considered unsafe, that is, they cannot reference programs or write directly to les. World writable :include: and .forward les are always unsafe.. UseErrorsTo [l] If there is an Errors-To: header, send error messages to the addresses listed there. They normally go to the envelope sender. Use of this option causes sendmail to violate RFC 1123. This option is disrecommended and deprecated.
UserDatabaseSpec=udbspec [U] The user database specication. Verbose [v] Run in verbose mode. If this is set, sendmail adjusts options HoldExpensive (old c) and DeliveryMode (old d) so that all mail is delivered completely in a
SMM:08-63
single job so that you can see the entire delivery process. Option Verbose should never be set in the conguration le; it is intended for command line use only. XscriptFileBufferSize=threshold [no short name] Set the threshold, in bytes, before a memory-based queue transcript le becomes disk-based. The default is 4096 bytes. All options can be specied on the command line using the O or o ag, but most will cause sendmail to relinquish its setuid permissions. The options that will not cause this are SevenBitInput [7], EightBitMode [8], MinFreeBlocks [b], CheckpointInterval [C], DeliveryMode [d], ErrorMode [e], IgnoreDots [i], SendMimeErrors [j], LogLevel [L], MeToo [m], OldStyleHeaders [o], PrivacyOptions [p], SuperSafe [s], Verbose [v], QueueSortOrder, MinQueueAge, DefaultCharSet, Dial Delay, NoRecipientAction, ColonOkInAddr, MaxQueueRunSize, SingleLineFromHeader, and AllowBogusHELO. Actually, PrivacyOptions [p] given on the command line are added to those already specied in the sendmail.cf le, i.e., they cant be reset. Also, M (dene macro) when dening the r or s macros is also considered safe. 5.7. P Precedence Denitions Values for the Precedence: eld may be dened using the P control line. The syntax of this eld is: Pname=num When the name is found in a Precedence: eld, the message class is set to num. Higher numbers mean higher precedence. Numbers less than zero have the special property that if an error occurs during processing the body of the message will not be returned; this is expected to be used for bulk mail such as through mailing lists. The default precedence is zero. For example, our list of precedences is: Prst-class=0 Pspecial-delivery=100 Plist=30 Pbulk=60 Pjunk=100 People writing mailing list exploders are encouraged to use Precedence: list. Older versions of sendmail (which discarded all error returns for negative precedences) didnt recognize this name, giving it a default precedence of zero. This allows list maintainers to see error returns on both old and new versions of sendmail. 5.8. V Conguration Version Level To provide compatibility with old conguration les, the V line has been added to dene some very basic semantics of the conguration le. These are not intended to be long term supports; rather, they describe compatibility features which will probably be removed in future releases. N.B.: these version levels have nothing to do with the version number on the les. For example, as of this writing version 8 cong les (specically, 8.10) used version level 9 congurations. Old conguration les are dened as version level one. Version level two les make the following changes: (1) Host name canonication ($[ ... $]) appends a dot if the name is recognized; this gives the cong le a way of nding out if anything matched. (Actually, this just initializes the host map with the a. ag you can reset it to anything you prefer by declaring the map explicitly.) Default host name extension is consistent throughout processing; version level one congurations turned off domain extension (that is, adding the local domain name) during certain points in processing. Version level two congurations are expected to include a trailing dot
(2)
SMM:08-64
to indicate that the name is already canonical. (3) Local names that are not aliases are passed through a new distinguished ruleset ve; this can be used to append a local relay. This behavior can be prevented by resolving the local name with an initial @. That is, something that resolves to a local mailer and a user name of vikki will be passed through ruleset ve, but a user name of @vikki will have the @ stripped, will not be passed through ruleset ve, but will otherwise be treated the same as the prior example. The expectation is that this might be used to implement a policy where mail sent to vikki was handled by a central hub, but mail sent to vikki@localhost was delivered directly.
Version level three les allow # initiated comments on all lines. Exceptions are backslash escaped # marks and the $# syntax. Version level four congurations are completely equivalent to level three for historical reasons. Version level ve conguration les change the default denition of $w to be just the rst component of the hostname. Version level six conguration les change many of the local processing options (such as aliasing and matching the beginning of the address for | characters) to be mailer ags; this allows ne-grained control over the special local processing. Level six conguration les may also use long option names. The ColonOkInAddr option (to allow colons in the local-part of addresses) defaults on for lower numbered conguration les; the conguration le requires some additional intelligence to properly handle the RFC 822 group construct. Version level seven conguration les used new option names to replace old macros ($e became SmtpGreetingMessage, $l became UnixFromLine, and $o became OperatorChars. Also, prior to version seven, the F=q ag (use 250 instead of 252 return value for SMTP VRFY commands) was assumed. Version level eight conguration les allow $# on the left hand side of ruleset lines. Version level nine conguration les allow parentheses in rulesets, i.e. they are not treated as comments and hence removed. The V line may have an optional /vendor to indicate that this conguration le uses modications specic to a particular vendor23. You may use /Berkeley to emphasize that this conguration le uses the Berkeley dialect of sendmail. 5.9. K Key File Declaration Special maps can be dened using the line: Kmapname mapclass arguments The mapname is the handle by which this map is referenced in the rewriting rules. The mapclass is the name of a type of map; these are compiled in to sendmail. The arguments are interpreted depending on the class; typically, there would be a single argument naming the le containing the map. Maps are referenced using the syntax: $( map key $@ arguments $: default $) where either or both of the arguments or default portion may be omitted. The $@ arguments may appear more than once. The indicated key and arguments are passed to the appropriate mapping
23 And of course, vendors are encouraged to add themselves to the list of recognized vendors by editing the routine setvendor in conf.c. Please send e-mail to [email protected] to register your vendor dialect.
SMM:08-65
function. If it returns a value, it replaces the input. If it does not return a value and the default is specied, the default replaces the input. Otherwise, the input is unchanged. The arguments are passed to the map for arbitrary use. Most map classes can interpolate these arguments into their values using the syntax %n (where n is a digit) to indicate the corresponding argument. Argument %0 indicates the database key. For example, the rule R$ ! $+ $: $(uucp $1 $@ $2 $: %1 @ %0 . UUCP $) Looks up the UUCP name in a (user dened) UUCP map; if not found it turns it into .UUCP form. The database might contain records like: decvax research %1@%0.DEC.COM %1@%0.ATT.COM
Note that default clauses never do this mapping. The built in map with both name and class host is the host name canonicalization lookup. Thus, the syntax: $(host hostname$) is equivalent to: $[hostname$] There are many dened classes. dbm btree hash nis nisplus Database lookups using the ndbm(3) library. Sendmail must be compiled with NDBM dened. Database lookups using the btree interface to the Berkeley DB library. Sendmail must be compiled with NEWDB dened. Database lookups using the hash interface to the Berkeley DB library. Sendmail must be compiled with NEWDB dened. NIS lookups. Sendmail must be compiled with NIS dened. NIS+ lookups. Sendmail must be compiled with NISPLUS dened. The argument is the name of the table to use for lookups, and the k and v ags may be used to set the key and value columns respectively. Hesiod lookups. Sendmail must be compiled with HESIOD dened. LDAP X500 directory lookups. Sendmail must be compiled with LDAPMAP dened. The map supports most of the standard arguments and most of the command line arguments of the ldapsearch program. Note that, by default, if a single query matches multiple values, only the rst value will be returned unless the z (value separator) map ag is set. Also, the 1 map ag will treat a multiple value return as if there were no matches. NeXT NetInfo lookups. Sendmail must be compiled with NETINFO dened. Text le lookups. The format of the text le is dened by the k (key eld number), v (value eld number), and z (eld delimiter) ags. PH query map. Contributed and supported by Mark Roth, [email protected]. For more information, consult the web site http://www-dev.cso.uiuc.edu/sendmail/. nsd map for IRIX 6.5 and later. Contributed and supported by Bob Mende of SGI, [email protected]. Internal symbol table lookups. Used internally for aliasing. Really should be called alias this is used to get the default lookups for alias les, and is the default if no class is specied for alias les.
hesiod ldap
SMM:08-66
user
Looks up users using getpwnam(3). The v ag can be used to specify the name of the eld to return (although this is normally used only to check the existence of a user). Canonies host domain names. Given a host name it calls the name server to nd the canonical name for that host. Returns the best MX record for a host name given as the key. The current machine is always preferred that is, if the current machine is one of the hosts listed as a lowest-preference MX record, then it will be guaranteed to be returned. This can be used to nd out if this machine is the target for an MX record, and mail can be accepted on that basis. If the z ag is given, then all MX names are returned, separated by the given delimiter. The arguments on the K line are a list of maps; the resulting map searches the argument maps in order until it nds a match for the indicated key. For example, if the key denition is: Kmap1 ... Kmap2 ... Kseqmap sequence map1 map2 then a lookup against seqmap rst does a lookup in map1. If that is found, it returns immediately. Otherwise, the same key is used for map2.
host bestmx
sequence
syslog switch
the key is logged via syslogd (8). The lookup returns the empty string. Much like the sequence map except that the order of maps is determined by the service switch. The argument is the name of the service to be looked up; the values from the service switch are appended to the map name to create new map names. For example, consider the key denition: Kali switch aliases together with the service switch entry: aliases nis les This causes a query against the map ali to search maps named ali.nis and ali.les in that order.
dequote
Strip double quotes (") from a name. It does not strip backslashes, and will not strip quotes if the resulting string would contain unscannable syntax (that is, basic errors like unbalanced angle brackets; more sophisticated errors such as unknown hosts are not checked). The intent is for use when trying to accept mail from systems such as DECnet that routinely quote odd syntax such as "49ers::ubell" A typical usage is probably something like: Kdequote dequote ... R$ R$ $+ $: $(dequote $1 $) $: $>3 $1 $2
Care must be taken to prevent unexpected results; for example, "|someprogram < input > output" will have quotes stripped, but the result is probably not what you had in mind. Fortunately these cases are rare.
SMM:08-67
regex
The map denition on the K line contains a regular expression. Any key input is compared to that expression using the POSIX regular expressions routines regcomp(), regerr(), and regexec(). Refer to the documentation for those routines for more information about the regular expression matching. No rewriting of the key is done if the m ag is used. Without it, the key is discarded or if s if used, it is substituted by the substring matches, delimited by $| or the string specied with the the d ag. The ags available for the map are -n -f -b -s -d -a -m -D not case sensitive basic regular expressions (default is extended) substring match set the delimiter used for -s append string to key match only, do not replace/discard value perform no lookup in deferred delivery mode.
The s ag can include an optional parameter which can be used to select the substrings in the result of the lookup. For example, -s1,3,4 Notes: to match a $ in a string, \$$ must be used. If the pattern contains spaces, they must be replaced with the blank substitution character, unless it is space itself. program The arguments on the K line are the pathname to a program and any initial parameters to be passed. When the map is called, the key is added to the initial parameters and the program is invoked as the default user/group id. The rst line of standard output is returned as the value of the lookup. This has many potential security problems, and has terrible performance; it should be used only when absolutely necessary. Set or clear a macro value. To set a macro, pass the value as the rst argument in the map lookup. To clear a macro, do not pass an argument in the map lookup. The map always returns the empty string. Example of typical usage include: Kstorage macro ... # set macro ${MyMacro} to the ruleset match R$+ $: $(storage {MyMacro} $@ $1 $) $1 # set macro ${MyMacro} to an empty string R$* $: $(storage {MyMacro} $@ $) $1 # clear macro ${MyMacro} R$ $: $(storage {MyMacro} $) $1 arith Perform simple arithmetic operations. The operation is given as key, currently +, -, *, /, l (for less than), and = are supported. The two operands are given as arguments. The lookup returns the result of the computation, i.e. TRUE or FALSE for comparisons, integer values otherwise. All options which are possible for maps are ignored. A simple example is:
macro
SMM:08-68
Most of these accept as arguments the same optional ags and a lename (or a mapname for NIS; the lename is the root of the database path, so that .db or some other extension appropriate for the database type will be added to get the actual database name). Known ags are: o N, O Indicates that this map is optional that is, if it cannot be opened, no error is produced, and sendmail will behave as if the map existed but was empty. If neither N or O are specied, sendmail uses an adaptive algorithm to decide whether or not to look for null bytes on the end of keys. It starts by trying both; if it nds any key with a null byte it never tries again without a null byte and vice versa. If N is specied it never tries without a null byte and if O is specied it never tries with a null byte. Setting one of these can speed matches but are never necessary. If both N and O are specied, sendmail will never try any matches at all that is, everything will appear to fail. Append the string x on successful matches. For example, the default host map appends a dot on successful matches. Append the string x on temporary failures. For example, x would be appended if a DNS lookup returned server failed or an NIS lookup could not locate a server. See also the t ag. Do not fold upper to lower case before looking up the key. Match only (without replacing the value). If you only care about the existence of a key and not the value (as you might when searching the NIS map hosts.byname for example), this ag prevents the map from substituting the value. However, The a argument is still appended on a match, and the default is still taken if the match fails. The key column name (for NIS+) or number (for text lookups). For LDAP maps this is an LDAP lter string in which %s is replaced with the literal contents of the lookup key and %0 is replaced with the LDAP escaped contents of the lookup key according to RFC2254. The value column name (for NIS+) or number (for text lookups). For LDAP maps this is the name of one or more attributes to be returned; multiple attributes can be separated by commas. If not specied, all attributes found in the match will be returned. The column delimiter (for text lookups). It can be a single character or one of the special strings \n or \t to indicate newline or tab respectively. If omitted entirely, the column separator is any sequence of white space. For LDAP maps this is the separator character to combine multiple values into a single return string. If not set, the LDAP lookup will only return the rst match found. Normally, when a map attempts to do a lookup and the server fails (e.g., sendmail couldnt contact any name server; this is not the same as an entry not being found in the map), the message being processed is queued for future processing. The t ag turns off this behavior, letting the temporary failure (server down) act as though it were a permanent failure (entry not found). It is particularly useful for DNS lookups, where someone elses miscongured name server can cause
ax Tx
f m
kkeycol
vvalcol
zdelim
SMM:08-69
problems on your machine. However, care must be taken to ensure that you dont bounce mail that would be resolved correctly if you tried again. A common strategy is to forward such mail to another, possibly better connected, mail server. D Sspacesub sspacesub q Llevel A Perform no lookup in deferred delivery mode. This ag is set by default for the host map. The character to use to replace space characters after a successful map lookup (esp. useful for regex and syslog maps). For the dequote map only, the character to use to replace space characters after a successful dequote. Dont dequote the key before lookup. For the syslog map only, it species the level to use for the syslog call. When rebuilding an alias le, the A ag causes duplicate entries in the text version to be merged. For example, two entries: list: list: list: in the presence of the A ag. The following additional ags are present in the ldap map only: R n rderef sscope hhost Do not auto chase referrals. sendmail must be compiled with DLDAP_REFERRALS to use this ag. Retrieve attribute names only. Set the alias dereference option to one of never, always, search, or nd. Set search scope to one of base, one (one level), or sub (subtree). LDAP server hostname. Some LDAP libraries allow you to specify multiple, space-separated hosts for redundancy. In addition, each of the hosts listed can be followed by a colon and a port number to override the default LDAP port. LDAP search base. LDAP service port. Time limit for LDAP queries. Size (number of matches) limit for LDAP queries. user1, user2 user3 user1, user2, user3
ddistinguished_name The distinguished name to use to login to the LDAP server. Mmethod Ppasswordle 1 The method to authenticate to the LDAP server. Should be one of LDAP_AUTH_NONE, LDAP_AUTH_SIMPLE, or LDAP_AUTH_KRBV4. The le containing the secret key for the LDAP_AUTH_SIMPLE authentication method or the name of the Kerberos ticket le for LDAP_AUTH_KRBV4. Force LDAP searches to only succeed if a single match is found. If multiple values are found, the search is treated as if no match was found.
The dbm map appends the strings .pag and .dir to the given lename; the hash and btree maps append .db. For example, the map specication Kuucp dbm o N /etc/mail/uucpmap species an optional map named uucp of class dbm; it always has null bytes at the end of every string, and the data is located in /etc/mail/uucpmap.{dir,pag}.
SMM:08-70
The program makemap(8) can be used to build any of the three database-oriented maps. It takes the following ags: f N o r v Do not fold upper to lower case in the map. Include null bytes in keys. Append to an existing (old) le. Allow replacement of existing keys; normally, re-inserting an existing key is an error. Print what is happening.
The sendmail daemon does not have to be restarted to read the new maps as long as you change them in place; le locking is used so that the maps wont be read while they are being updated. New classes can be added in the routine setupmaps in le conf.c. 5.10. The User Database If you have a version of sendmail with the user database package compiled in, the handling of sender and recipient addresses is modied. The location of this database is controlled with the UserDatabaseSpec option. 5.10.1. Structure of the user database The database is a sorted (BTree-based) structure. User records are stored with the key: user-name:eld-name The sorted database format ensures that user records are clustered together. Meta-information is always stored with a leading colon. Field names dene both the syntax and semantics of the value. Dened elds include: maildrop The delivery address for this user. There may be multiple values of this record. In particular, mailing lists will have one maildrop record for each user on the list. The outgoing mailname for this user. For each outgoing name, there should be an appropriate maildrop record for that name to allow return mail. See also :default:mailname. Changes any mail sent to this address to have the indicated envelope sender. This is intended for mailing lists, and will normally be the name of an appropriate -request address. It is very similar to the owner-list syntax in the alias le. The full name of the user. The ofce address for this user. The ofce phone number for this user. The ofce FAX number for this user. The home address for this user. The home phone number for this user. The home FAX number for this user. A (short) description of the project this person is afliated with. In the University this is often just the name of their graduate advisor. A pointer to a le from which plan information can be gathered.
mailname
mailsender
SMM:08-71
As of this writing, only a few of these elds are actually being used by sendmail: maildrop and mailname. A nger program that uses the other elds is planned. 5.10.2. User database semantics When the rewriting rules submit an address to the local mailer, the user name is passed through the alias le. If no alias is found (or if the alias points back to the same address), the name (with :maildrop appended) is then used as a key in the user database. If no match occurs (or if the maildrop points at the same address), forwarding is tried. If the rst token of the user name returned by ruleset 0 is an @ sign, the user database lookup is skipped. The intent is that the user database will act as a set of defaults for a cluster (in our case, the Computer Science Division); mail sent to a specic machine should ignore these defaults. When mail is sent, the name of the sending user is looked up in the database. If that user has a mailname record, the value of that record is used as their outgoing name. For example, I might have a record: eric:mailname [email protected] This would cause my outgoing mail to be sent as Eric.Allman. If a maildrop is found for the user, but no corresponding mailname record exists, the record :default:mailname is consulted. If present, this is the name of a host to override the local host. For example, in our case we would set it to CS.Berkeley.EDU. The effect is that anyone known in the database gets their outgoing mail stamped as [email protected], but people not listed in the database use the local hostname. 5.10.3. Creating the database24 The user database is built from a text le using the makemap utility (in the distribution in the makemap subdirectory). The text le is a series of lines corresponding to userdb records; each line has a key and a value separated by white space. The key is always in the format described above for example: eric:maildrop This le is normally installed in a system directory; for example, it might be called /etc/mail/userdb. To make the database version of the map, run the program: makemap btree /etc/mail/userdb < /etc/mail/userdb Then create a cong le that uses this. For example, using the V8 M4 conguration, include the following line in your .mc le: dene(`confUSERDB_SPEC, /etc/mail/userdb.db) 6. OTHER CONFIGURATION There are some conguration changes that can be made by recompiling sendmail. This section describes what changes can be made and what has to be modied to make them. In most cases this should be unnecessary unless you are porting sendmail to a new environment.
24 These instructions are known to be incomplete. Other features are available which provide similar functionality, e.g., virtual hosting and mapping local addresses into a generic form as explained in cf/README.
SMM:08-72
6.1. Parameters in devtools/OS/$oscf These parameters are intended to describe the compilation environment, not site policy, and should normally be dened in the operating system conguration le. This section needs a complete rewrite. NDBM If set, the new version of the DBM library that allows multiple databases will be used. If neither NDBM nor NEWDB are set, a much less efcient method of alias lookup is used. If set, use the new database package from Berkeley (from 4.4BSD). This package is substantially faster than DBM or NDBM. If NEWDB and NDBM are both set, sendmail will read DBM les, but will create and use NEWDB les. Include support for NIS. If set together with both NEWDB and NDBM, sendmail will create both DBM and NEWDB les if and only if an alias le includes the substring /yp/ in the name. This is intended for compatibility with Sun Microsystems mkalias program used on YP masters. Compile in support for NIS+. Compile in support for NetInfo (NeXT stations). Compile in support for LDAP X500 queries. Requires libldap and liblber from the Umich LDAP 3.2 or 3.3 release or equivalent libraries for other LDAP libraries such as OpenLDAP. Compile in support for Hesiod. Compile in support for IRIX NSD lookups. Compile in support for regular expression matching. Compile in support for ph lookups. Compile in support for SASL, a required component for SMTP Authentication support. Compile in support for STARTTLS. Compile in support for the "Entropy Gathering Daemon" to provide better random data for TLS. Compile in support for so, which is required to enable encryption, e.g., STARTTLS.
NEWDB
NIS
TCPWRAPPERS Compile in support for TCP Wrappers. _PATH_SENDMAILCF The pathname of the sendmail.cf le. _PATH_SENDMAILPID The pathname of the sendmail.pid le. There are also several compilation ags to indicate the environment such as _AIX3 and _SCO_unix_. See the sendmail/README le for the latest scoop on these ags. 6.2. Parameters in sendmail/conf.h Parameters and compilation options are dened in conf.h. Most of these need not normally be tweaked; common parameters are all in sendmail.cf. However, the sizes of certain primitive vectors, etc., are included in this le. The numbers following the parameters are their default value. This document is not the best source of information for compilation ags in conf.h see sendmail/README or sendmail/conf.h itself.
SMM:08-73
MAXLINE [2048]
The maximum line length of any input line. If message lines exceed this length they will still be processed correctly; however, header lines, conguration le lines, alias lines, etc., must t within this limit. The maximum number of parameters to any mailer. This limits the number of recipients that may be passed in one transaction. It can be set to any arbitrary number above about 10, since sendmail will break up a delivery into smaller batches as needed. A higher number may reduce load on your system, however.
MAXNAME [256] The maximum length of any name, such as a host or a user name. MAXPV [256]
MAXATOM [1000] The maximum number of atoms (tokens) in a single address. For example, the address [email protected] is seven atoms. MAXMAILERS [25]The maximum number of mailers that may be dened in the conguration le. This value is dened in include/sendmail/sendmail.h. MAXRWSETS [200]The maximum number of rewriting sets that may be dened. The rst half of these are reserved for numeric specication (e.g., S92), while the upper half are reserved for auto-numbering (e.g., Sfoo). Thus, with a value of 200 an attempt to use S99 will succeed, but S100 will fail. MAXPRIORITIES [25] The maximum number of values for the Precedence: eld that may be dened (using the P line in sendmail.cf). MAXUSERENVIRON [100] The maximum number of items in the user environment that will be passed to subordinate mailers. MAXMXHOSTS [100] The maximum number of MX records we will accept for any single host. MAXALIASDB [12]The maximum number of alias databases that can be open at any time. Note that there may also be an open le limit. MAXMAPSTACK [12] The maximum number of maps that may be "stacked" in a sequence class map. MAXMIMEARGS [20] The maximum number of arguments in a MIME Content-Type: header; additional arguments will be ignored. MAXMIMENESTING [20] The maximum depth to which MIME messages may be nested (that is, nested Message or Multipart documents; this does not limit the number of components in a single Multipart document). MAXDAEMONS [10] The maximum number of sockets sendmail will open for accepting connections on different ports. MAXMACNAMELEN [25] The maximum length of a macro name. A number of other compilation options exist. These specify whether or not specic code should be compiled in. Ones marked with are 0/1 valued. NETINET If set, support for Internet protocol networking is compiled in. Previous versions of sendmail referred to this as DAEMON; this old usage is now incorrect. Defaults on; turn it off in the Makele if your system doesnt support the
SMM:08-74
Internet protocols. NETINET6 NETISO NETUNIX LOG If set, support for IPv6 networking is compiled in. It must be separately enabled by adding DaemonPortOptions settings. If set, support for ISO protocol networking is compiled in (it may be appropriate to #dene this in the Makele instead of conf.h). If set, support for UNIX domain sockets is compiled in. This is used for control socket support. If set, the syslog routine in use at some sites is used. This makes an informational log record for each message processed, and makes a higher priority log record for internal system errors. STRONGLY RECOMMENDED if you want no logging, turn it off in the conguration le. Compile in the code to do fuzzy matching on the GECOS eld in /etc/passwd. This also requires that the MatchGECOS option be turned on. Compile in code to use the Berkeley Internet Name Domain (BIND) server to resolve TCP/IP host names. If you are using a non-UNIX mail format, you can set this ag to turn off special processing of UNIX-style From lines. This ag should be set to compile in the queueing code. If this is not set, mailers must accept the mail immediately or it will be returned to the sender. If set, the code to handle user and server SMTP will be compiled in. This is only necessary if your machine has some mailer that speaks SMTP (this means most machines everywhere). Include the experimental Berkeley user information database package. This adds a new level of local name expansion between aliasing and forwarding. It also uses the NEWDB package. This may change in future releases. Compile in the IDENT protocol as dened in RFC 1413. This defaults on for all systems except Ultrix, which apparently has the interesting feature that when it receives a host unreachable message it closes all open connections to that host. Since some rewall gateways send this error code when you access an unauthorized port (such as 113, used by IDENT), Ultrix cannot receive email from such hosts. Set all of the compilation parameters appropriate for System V. Use Berkeley-style ock instead of System V lockf to do le locking. Due to the highly unusual semantics of locks across forks in lockf, this should always be used if at all possible.
USERDB
The following options are normally turned on in per-operating-system clauses in conf.h. IDENTPROTO
SYSTEM5 HASFLOCK
HASINITGROUPS Set this if your system has the initgroups() call (if you have multiple group support). This is the default if SYSTEM5 is not dened or if you are on HPUX. HASUNAME Set this if you have the uname(2) system call (or corresponding library routine). Set by default if SYSTEM5 is set.
HASGETDTABLESIZE Set this if you have the getdtablesize(2) system call. HASWAITPID Set this if you have the haswaitpid(2) system call. FAST_PID_RECYCLE Set this if your system can possibly reuse the same pid in the same second of
SMM:08-75
time. SFS_TYPE The mechanism that can be used to get le system capacity information. The values can be one of SFS_USTAT (use the ustat(2) syscall), SFS_4ARGS (use the four argument statfs(2) syscall), SFS_VFS (use the two argument statfs(2) syscall including <sys/vfs.h>), SFS_MOUNT (use the two argument statfs(2) syscall including <sys/mount.h>), SFS_STATFS (use the two argument statfs(2) syscall including <sys/statfs.h>), SFS_STATVFS (use the two argument statfs(2) syscall including <sys/statvfs.h>), or SFS_NONE (no way to get this information). The load average type. Details are described below.
LA_TYPE
The are several built-in ways of computing the load average. Sendmail tries to auto-congure them based on imperfect guesses; you can select one using the cc option DLA_TYPE=type, where type is: LA_INT LA_SHORT LA_FLOAT LA_MACH LA_SUBR LA_ZERO The kernel stores the load average in the kernel as an array of long integers. The actual values are scaled by a factor FSCALE (default 256). The kernel stores the load average in the kernel as an array of short integers. The actual values are scaled by a factor FSCALE (default 256). The kernel stores the load average in the kernel as an array of double precision oats. Use MACH-style load averages. Call the getloadavg routine to get the load average as an array of doubles. Always return zero as the load average. This is the fallback case.
If type LA_INT, LA_SHORT, or LA_FLOAT is specied, you may also need to specify _PATH_UNIX (the path to your system binary) and LA_AVENRUN (the name of the variable containing the load average in the kernel; usually _avenrun or avenrun). 6.3. Conguration in sendmail/conf.c The following changes can be made in conf.c. 6.3.1. Built-in Header Semantics Not all header semantics are dened in the conguration le. Header lines that should only be included by certain mailers (as well as other more obscure semantics) must be specied in the HdrInfo table in conf.c. This table contains the header name (which should be in all lower case) and a set of header control ags (described below), The ags are: H_ACHECK Normally when the check is made to see if a header line is compatible with a mailer, sendmail will not delete an existing line. If this ag is set, sendmail will delete even existing header lines. That is, if this bit is set and the mailer does not have ag bits set that intersect with the required mailer ags in the header denition in sendmail.cf, the header line is always deleted. If this header eld is set, treat it like a blank line, i.e., it will signal the end of the header and the beginning of the message text. Add this header entry even if one existed in the message before. If a header entry does not have this bit set, sendmail will not add another header line if a header line of this name already existed. This would normally be used to stamp the message by everyone who handled it.
H_EOH H_FORCE
SMM:08-76
H_TRACE
If set, this is a timestamp (trace) eld. If the number of trace elds in a message exceeds a preset amount the message is returned on the assumption that it has an aliasing loop. If set, this eld contains recipient addresses. This is used by the t ag to determine who to send to when it is collecting recipients from the message. This ag indicates that this eld species a sender. The order of these elds in the HdrInfo table species sendmails preference for which eld to return error messages to. Addresses in this header should receive error messages. This header is a Content-Transfer-Encoding header. This header is a Content-Type header. Strip the value from the header (for Bcc:).
H_RCPT
H_FROM
Lets look at a sample HdrInfo specication: struct hdrinfo HdrInfo[] = { /* originator elds, most to least signicant */ "resent-sender", H_FROM, "resent-from", H_FROM, "sender", H_FROM, "from", H_FROM, "full-name", H_ACHECK, "errors-to", H_FROM | H_ERRORSTO, /* destination elds */ "to", H_RCPT, "resent-to", H_RCPT, "cc", H_RCPT, "bcc", H_RCPT|H_STRIPVAL, /* message identication and control */ "message", H_EOH, "text", H_EOH, /* trace elds */ "received", H_TRACE | H_FORCE, /* miscellaneous elds */ "content-transfer-encoding", H_CTE, "content-type", H_CTYPE, NULL, }; This structure indicates that the To:, Resent-To:, and Cc: elds all specify recipient addresses. Any Full-Name: eld will be deleted unless the required mailer ag (indicated in the conguration le) is specied. The Message: and Text: elds will terminate the header; these are used by random dissenters around the network world. The Received: eld will always be added, and can be used to trace messages. There are a number of important points here. First, header elds are not added automatically just because they are in the HdrInfo structure; they must be specied in the conguration le in order to be added to the message. Any header elds mentioned in the conguration le but not mentioned in the HdrInfo structure have default processing performed; that is, they are added unless they were in the message already. Second, the HdrInfo structure only species 0,
SMM:08-77
cliched processing; certain headers are processed specially by ad hoc code regardless of the status specied in HdrInfo. For example, the Sender: and From: elds are always scanned on ARPANET mail to determine the sender25; this is used to perform the return to sender function. The From: and Full-Name: elds are used to determine the full name of the sender if possible; this is stored in the macro $x and used in a number of ways. 6.3.2. Restricting Use of Email If it is necessary to restrict mail through a relay, the checkcompat routine can be modied. This routine is called for every recipient address. It returns an exit status indicating the status of the message. The status EX_OK accepts the address, EX_TEMPFAIL queues the message for a later try, and other values (commonly EX_UNAVAILABLE) reject the message. It is up to checkcompat to print an error message (using usrerr) if the message is rejected. For example, checkcompat could read:
int checkcompat(to, e) register ADDRESS *to; register ENVELOPE *e; { register STAB *s; s = stab("private", ST_MAILER, ST_FIND); if (s != NULL && e>e_from.q_mailer != LocalMailer && to->q_mailer == s->s_mailer) { usrerr("No private net mail allowed through this machine"); return (EX_UNAVAILABLE); } if (MsgSize > 50000 && bitnset(M_LOCALMAILER, to>q_mailer)) { usrerr("Message too large for non-local delivery"); e>e_ags |= EF_NORETURN; return (EX_UNAVAILABLE); } return (EX_OK); }
This would reject messages greater than 50000 bytes unless they were local. The EF_NORETURN ag can be set in ee_ags to suppress the return of the actual body of the message in the error return. The actual use of this routine is highly dependent on the implementation, and use should be limited. 6.3.3. New Database Map Classes New key maps can be added by creating a class initialization function and a lookup function. These are then added to the routine setupmaps. The initialization function is called as xxx_map_init(MAP *map, char *args) The map is an internal data structure. The args is a pointer to the portion of the conguration le line following the map class name; ags and lenames can be extracted from this line. The initialization function must return TRUE if it successfully opened the map, FALSE otherwise.
25 Actually, this is no longer true in SMTP; this information is contained in the envelope. The older ARPANET protocols did not completely distinguish envelope from header.
SMM:08-78
The lookup function is called as xxx_map_lookup(MAP *map, char buf[], char **av, int *statp) The map denes the map internally. The buf has the input key. This may be (and often is) used destructively. The av is a list of arguments passed in from the rewrite line. The lookup function should return a pointer to the new value. If the map lookup fails, *statp should be set to an exit status code; in particular, it should be set to EX_TEMPFAIL if recovery is to be attempted by the higher level code. 6.3.4. Queueing Function The routine shouldqueue is called to decide if a message should be queued or processed immediately. Typically this compares the message priority to the current load average. The default denition is: bool shouldqueue(pri, ctime) long pri; time_t ctime; { if (CurrentLA < QueueLA) return (FALSE); return (pri > (QueueFactor / (CurrentLA QueueLA + 1))); } If the current load average (global variable CurrentLA, which is set before this function is called) is less than the low threshold load average (option x, variable QueueLA), shouldqueue returns FALSE immediately (that is, it should not queue). If the current load average exceeds the high threshold load average (option X, variable RefuseLA), shouldqueue returns TRUE immediately. Otherwise, it computes the function based on the message priority, the queue factor (option q, global variable QueueFactor), and the current and threshold load averages. An implementation wishing to take the actual age of the message into account can also use the ctime parameter, which is the time that the message was rst submitted to sendmail. Note that the pri parameter is already weighted by the number of times the message has been tried (although this tends to lower the priority of the message with time); the expectation is that the ctime would be used as an escape clause to ensure that messages are eventually processed. 6.3.5. Refusing Incoming SMTP Connections The function refuseconnections returns TRUE if incoming SMTP connections should be refused. The current implementation is based exclusively on the current load average and the refuse load average option (option X, global variable RefuseLA): bool refuseconnections() { return (RefuseLA > 0 && CurrentLA >= RefuseLA); } A more clever implementation could look at more system resources. 6.3.6. Load Average Computation The routine getla returns the current load average (as a rounded integer). The distribution includes several possible implementations. If you are porting to a new environment you may
SMM:08-79
need to add some new tweaks.26 6.4. Conguration in sendmail/daemon.c The le sendmail/daemon.c contains a number of routines that are dependent on the local networking environment. The version supplied assumes you have BSD style sockets. In previous releases, we recommended that you modify the routine maphostname if you wanted to generalize $[ ... $] lookups. We now recommend that you create a new keyed map instead. 6.5. Certicates for STARTTLS In this section we assume that sendmail has been compiled with support for STARTTLS. When acting as a server, sendmail requires X.509 certicates to support STARTTLS: one as certicate for the server (ServerCertFile) at least one root CA (CACERTFile), i.e., a certicate that is used to sign other certicates, and a path to a directory which contains other CAs (CACERTPath). The le specied via CACERTFile can contain several certicates of CAs. The DNs of these certicates are sent to the client during the TLS handshake (as part of the CerticateRequest) as the list of acceptable CAs. An X.509 certicate is also required for authentication in client mode (ClientCertFile), however, sendmail will always use STARTTLS when offered by a server. The client and server certicates can be identical. Certicates can be obtained from a certicate authority or created with the help of OpenSSL. The required format for certicates and private keys is PEM. To allow for automatic startup of sendmail, private keys (ServerKeyFile, ClientKeyFile) must be stored unencrypted. The keys are only protected by the permissions of the le system. Never make a private key available to a third party. 6.6. PRNG for STARTTLS STARTTLS requires a strong pseudo random number generator (PRNG) to operate properly. Depending on the TLS library you use, it may be required to explicitly initialize the PRNG with random data. OpenSSL makes use of /dev/urandom(4) if available (this corresponds to the compile ag HASURANDOMDEV). On systems which lack this support, a random le must be specied in the sendmail.cf le using the option RandFile. It is strongly advised to use the "Entropy Gathering Daemon" EGD from Brian Warner on those systems to provide useful random data. In this case, sendmail must be compiled with the ag EGD, and the RandFile option must point to the EGD socket. If neither /dev/urandom(4) nor EGD are available, you have to make sure that useful random data is available all the time in RandFile. If the le hasnt been modied in the last 10 minutes before it is supposed to be used by sendmail the content is considered obsolete. One method for generating this le is: openssl rand -out /etc/mail/randle -rand /path/to/le:...256 See the OpenSSL documentation for more information. In this case, the PRNG for TLS is only seeded with other random data if the DontBlameSendmail option InsufcientEntropy is set. This is most likely not sufcient for certain actions, e.g., generation of (temporary) keys. Please see the OpenSSL documentation or other sources for further information about certicates, their creation and their usage, the importance of a good PRNG, and other aspects of TLS. 7. ACKNOWLEDGEMENTS Ive worked on sendmail for many years, and many employers have been remarkably patient about letting me work on a large project that was not part of my ofcial job. This includes time on the INGRES Project at the University of California at Berkeley, at Britton Lee, and again on the Mammoth
26
SMM:08-80
and Titan Projects at Berkeley. Much of the second wave of improvements resulting in version 8.1 should be credited to Bryan Costales of the International Computer Science Institute. As he passed me drafts of his book on sendmail I was inspired to start working on things again. Bryan was also available to bounce ideas off of. Gregory Neil Shapiro of Worcester Polytechnic Institute has become instrumental in all phases of sendmail support and development, and was largely responsible for getting versions 8.8 and 8.9 out the door. Many, many people contributed chunks of code and ideas to sendmail. It has proven to be a group network effort. Version 8 in particular was a group project. The following people and organizations made notable contributions: Claus Assmann John Beck, Hewlett-Packard & Sun Microsystems Keith Bostic, CSRG, University of California, Berkeley Andrew Cheng, Sun Microsystems Michael J. Corrigan, University of California, San Diego Bryan Costales, International Computer Science Institute & InfoBeat .. Par (Pell) Emanuelsson Craig Everhart, Transarc Corporation Per Hedeland, Ericsson Tom Ivar Helbekkmo, Norwegian School of Economics Kari Hurtta, Finnish Meteorological Institute Allan E. Johannesen, WPI Jonathan Kamens, OpenVision Technologies, Inc. Takahiro Kanbe, Fuji Xerox Information Systems Co., Ltd. Brian Kantor, University of California, San Diego John Kennedy, Cal State University, Chico Murray S. Kucherawy, HookUp Communication Corp. Bruce Lilly, Sony U.S. Karl London Motonori Nakamura, Ritsumeikan University & Kyoto University John Gardiner Myers, Carnegie Mellon University Neil Rickert, Northern Illinois University Gregory Neil Shapiro, WPI Eric Schnoebelen, Convex Computer Corp. Eric Wassenaar, National Institute for Nuclear and High Energy Physics, Amsterdam Randall Winchester, University of Maryland Christophe Wolfhugel, Pasteur Institute & Herve Schauer Consultants (Paris) Exactis.com, Inc. I apologize for anyone I have omitted, misspelled, misattributed, or otherwise missed. At this point, I suspect that at least a hundred people have contributed code, and many more have contributed ideas, comments, and encouragement. Ive tried to list them in the RELEASE_NOTES in the distribution directory. I appreciate their contribution as well. Special thanks are reserved for Michael Corrigan and Christophe Wolfhugel, who besides being wonderful guinea pigs and contributors have also consented to be added to the [email protected] list and, by answering the bulk of the questions sent to that list, have freed me up to do other work.
APPENDIX A
Arguments must be presented with ags before addresses. The ags are: bx Set operation mode to x. Operation modes are: m s a d D t v i p h H Btype Cle dlevel f addr Deliver mail (default) Speak SMTP on input side Arpanet mode (get envelope sender information from header) Run as a daemon in background Run as a daemon in foreground Run in test mode Just verify addresses, dont collect or deliver Initialize the alias database Print the mail queue Print the persistent host status database Purge expired entries from the persistent host status database
Indicate body type. Use a different conguration le. Sendmail runs as the invoking user (rather than root) when this ag is specied. Set debugging level. The envelope sender address is set to addr. This address may also be used in the From: header if that header is missing during initial submission. The envelope sender address is used as the recipient for delivery status notications and may also appear in a ReturnPath: header. Sets the full name of this user to name. When accepting messages via the command line, indicate that they are for relay (gateway) submission. sendmail may complain about syntactically invalid messages, e.g., unqualied host names, rather than xing them when this ag is set. sendmail will not do any canonicalization in this mode. Sets the hop count to cnt. This represents the number of times this message has been processed by sendmail (to the extent that it is supported by the underlying networks). Cnt is incremented during processing, and if it reaches MAXHOP (currently 30) sendmail throws away the message with an error. Sets the identier used for syslog. Note that this identier is set as early as possible. However, sendmail may be used if problems arise before the command line arguments are processed. Dont do aliasing or forwarding.
F name G
h cnt
L tag
N notications Tag all addresses being sent as wanting the indicated notications, which consists of the word NEVER or a comma-separated list of SUCCESS, FAILURE, and DELAY
Deprecated.
SMM:08-81
SMM:08-82
for successful delivery, failure, and a message that is stuck in a queue somewhere. The default is FAILURE,DELAY. r addr ox value An obsolete form of f. Set option x to the specied value. These options are described in Section 5.6.
Ooption=value Set option to the specied value (for long form option names). These options are described in Section 5.6. Mx value pprotocol Set macro x to the specied value. Set the sending protocol. Programs are encouraged to set this. The protocol eld can be in the form protocol:host to set both the sending protocol and sending host. For example, pUUCP:uunet sets the sending protocol to UUCP and the sending host to uunet. (Some existing programs use oM to set the r and s macros; this is equivalent to using p.) Try to process the queued up mail. If the time is given, a sendmail will run through the queue at the specied interval to deliver queued mail; otherwise, it only runs once. Run the queue once, limiting the jobs to those matching Xstring. The key letter X can be I to limit based on queue identier, R to limit based on recipient, or S to limit based on sender. A particular queued job is accepted if one of the corresponding addresses contains the indicated string. Multiple qX ags are permitted, with items with the same key letter ored together, and items with different key letters anded together. What information you want returned if the message bounces; ret can be HDRS for headers only or FULL for headers plus body. This is a request only; the other end is not required to honor the parameter. If HDRS is specied local bounces also return only the headers. Read the header for To:, Cc:, and Bcc: lines, and send to everyone listed in those lists. The Bcc: line will be deleted before sending. Any addresses in the argument vector will be deleted from the send list. Indicate that this is an initial User Agent submission. This ag is deprecated. Future releases will ignore this ag and assume all submissions from the command line are initial submissions. The indicated envid is passed with the envelope of the message and returned if the message bounces. Log all trafc in and out of sendmail in the indicated logle for debugging mailer problems. This produces a lot of data very quickly and should be used sparingly.
qtime qXstring
R ret
V envid X logle
There are a number of options that may be specied as primitive ags. These are the e, i, m, and v options. Also, the f option may be specied as the s ag. The DSN related options N, R, and V have no effects on sendmail running as daemon.
APPENDIX B
This appendix describes the format of the queue les. These les live in the directory dened by the Q option in the sendmail.cf le, usually /var/spool/mqueue or /usr/spool/mqueue. The individual qf, df, and xf les may be stored in separate qf/, df/, and xf/ subdirectories if they are present in the queue directory. To use multiple queues, supply a value ending with an asterisk. For example, /var/spool/mqueue/q* will use all of the directories or symbolic links to directories beginning with q in /var/spool/mqueue as queue directories. New messages will be randomly placed into one of the queues. Do not change the queue directory structure while sendmail is running. All queue les have the name x fYMDhmsNPPPPP where YMDhmsNPPPPP is the id for this message and the x is a type. The individual letters in the id are: Y M D h m s N Encoded year Encoded month Encoded day Encoded hour Encoded minute Encoded second Envelope number
PPPPP At least ve digits of the process ID All les with the same id collectively dene one message. If memory-buffered les are available, some of these les may never appear on disk. The types are: d q t x The data le. The message body (excluding the header) is kept in this le. The queue control le. This le contains the information necessary to process the job. A temporary le. These are an image of the qf le when it is being rebuilt. It should be renamed to a qf le very quickly. A transcript le, existing during the life of a session showing everything that happens during that session. The qf le is structured as a series of lines each beginning with a code letter. The lines are as follows: V The version number of the queue le format, used to allow new sendmail binaries to read queue les created by older versions. Defaults to version zero. Must be the rst line of the le if present. For 8.10 the version number is 4. The information given by the AUTH= parameter of the MAIL FROM: command or $f@$j if sendmail has been called directly. A header denition. There may be any number of these lines. The order is important: they represent the order in the nal message. These use the same syntax as header denitions in the conguration le.
A H
SMM:08-83
SMM:08-84
The controlling address. The syntax is localuser:aliasname. Recipient addresses following this line will be agged so that deliveries will be run as the localuser (a user name from the /etc/passwd le); aliasname is the name of the alias that expanded to this address (used for printing messages). The original recipient, specied by the ORCPT= eld in an ESMTP transaction. Used exclusively for Delivery Status Notications. It applies only to the immediately following R line. A recipient address. This will normally be completely aliased, but is actually realiased when the job is processed. There will be one line for each recipient. Version 1 qf les also include a leading colon-terminated list of ags, which can be S to return a message on successful nal delivery, F to return a message on failure, D to return a message if the message is delayed, B to indicate that the body should be returned, N to suppress returning the body, and P to declare this as a primary (command line or SMTP-session) address. The sender address. There may only be one of these lines. The job creation time. This is used to compute when to time out the job. The current message priority. This is used to order the queue. Higher numbers mean lower priorities. The priority changes as the message sits in the queue. The initial priority depends on the message class and the size of the message. A message. This line is printed by the mailq command, and is generally used to store status information. It can contain any text. Flag bits, represented as one letter per ag. Dened ag bits are r indicating that this is a response message and w indicating that a warning message has been sent announcing that the mail has been delayed. The total number of delivery attempts. The time (as seconds since January 1, 1970) of the last delivery attempt. The i-number of the data le; this can be used to recover your mail queue after a disastrous disk crash. A macro denition. The values of certain macros (as of this writing, only $r and $s) are passed through to the queue run phase. The body type. The remainder of the line is a text string dening the body type. If this eld is missing, the body type is assumed to be undened and no special processing is attempted. Legal values are 7BIT and 8BITMIME. The original envelope id (from the ESMTP transaction). For Deliver Status Notications only.
Q R
S T P
M F
N K I $ B
1 This example is contrived and probably inaccurate for your environment. Glance over it to get an idea; nothing can replace looking at what your own system generates.
SMM:08-85
V4 T711358135 K904446490 N0 P2100941 $_eric@localhost ${daemon_ags} Seric Ceric:100:1000:[email protected] RPFD:[email protected] RPFD:[email protected] H?P?Return-path: <g> H??Received: by vangogh.CS.Berkeley.EDU (5.108/2.7) id AAA06703; Fri, 17 Jul 1992 00:28:55 -0700 H??Received: from mail.CS.Berkeley.EDU by vangogh.CS.Berkeley.EDU (5.108/2.7) id AAA06698; Fri, 17 Jul 1992 00:28:54 -0700 H??Received: from [128.32.31.21] by mail.CS.Berkeley.EDU (5.96/2.5) id AA22777; Fri, 17 Jul 1992 03:29:14 -0400 H??Received: by foo.bar.baz.de (5.57/Ultrix3.0-C) id AA22757; Fri, 17 Jul 1992 09:31:25 GMT H?F?From: [email protected] (Eric Allman) H?x?Full-name: Eric Allman H??Message-id: <[email protected]> H??To: [email protected] H??Subject: this is an example message This shows the person who sent the message, the submission time (in seconds since January 1, 1970), the message priority, the message class, the recipients, and the headers for the message.
APPENDIX C
This is a summary of the support les that sendmail creates or generates. Many of these can be changed by editing the sendmail.cf le; check there to nd the actual pathnames. /usr/sbin/sendmail The binary of sendmail. /usr/bin/newaliases A link to /usr/sbin/sendmail; causes the alias database to be rebuilt. Running this program is completely equivalent to giving sendmail the bi ag. /usr/bin/mailq Prints a listing of the mail queue. This program is equivalent to using the bp ag to sendmail.
/etc/mail/sendmail.cf The conguration le, in textual form. /etc/mail/helple The SMTP help le. /etc/mail/statistics A statistics le; need not be present. /etc/mail/sendmail.pid Created in daemon mode; it contains the process id of the current SMTP daemon. If you use this in scripts; use head 1 to get just the rst line; the second line contains the command line used to invoke the daemon, and later versions of sendmail may add more information to subsequent lines. /etc/mail/aliases The textual version of the alias le. /etc/mail/aliases.db The alias le in hash (3) format. /etc/mail/aliases.{pag,dir} The alias le in ndbm (3) format. /var/spool/mqueue The directory in which the mail queue(s) and temporary les reside. /var/spool/mqueue/qf* Control (queue) les for messages. /var/spool/mqueue/df* Data les. /var/spool/mqueue/tf* Temporary versions of the qf les, used during queue le rebuild. /var/spool/mqueue/xf* A transcript of the current session.
SMM:08-86
SMM:08-3
TABLE OF CONTENTS
1. BASIC INSTALLATION ............................................................................................................... 1.1. Compiling Sendmail .............................................................................................................. 1.1.1. Tweaking the Build Invocation ..................................................................................... 1.1.2. Creating a Site Conguration File ................................................................................ 1.1.3. Tweaking the Makele ................................................................................................. 1.1.4. Compilation and installation ........................................................................................ 1.2. Conguration Files ................................................................................................................ 1.3. Details of Installation Files ................................................................................................... 1.3.1. /usr/sbin/sendmail ......................................................................................................... 1.3.2. /etc/mail/sendmail.cf .................................................................................................... 1.3.3. /usr/bin/newaliases ....................................................................................................... 1.3.4. /usr/bin/hoststat ............................................................................................................ 1.3.5. /usr/bin/purgestat .......................................................................................................... 1.3.6. /var/spool/mqueue ........................................................................................................ 1.3.7. /var/spool/mqueue/.hoststat .......................................................................................... 1.3.8. /etc/mail/aliases* .......................................................................................................... 1.3.9. /etc/rc or /etc/init.d/sendmail ........................................................................................ 1.3.10. /etc/mail/helple ......................................................................................................... 1.3.11. /etc/mail/statistics ....................................................................................................... 1.3.12. /usr/bin/mailq ............................................................................................................. 2. NORMAL OPERATIONS ............................................................................................................. 2.1. The System Log .................................................................................................................... 2.1.1. Format .......................................................................................................................... 2.1.2. Levels ........................................................................................................................... 2.2. Dumping State ....................................................................................................................... 2.3. The Mail Queue ..................................................................................................................... 2.3.1. Printing the queue ......................................................................................................... 2.3.2. Forcing the queue ......................................................................................................... 2.4. Disk Based Connection Information ..................................................................................... 2.5. The Service Switch ................................................................................................................ 2.6. The Alias Database ................................................................................................................ 2.6.1. Rebuilding the alias database ....................................................................................... 2.6.2. Potential problems ........................................................................................................ 2.6.3. List owners ................................................................................................................... 2.7. User Information Database .................................................................................................... 2.8. Per-User Forwarding (.forward Files) ................................................................................... 2.9. Special Header Lines ............................................................................................................. 2.9.1. Errors-To: ..................................................................................................................... 2.9.2. Apparently-To: ............................................................................................................. 2.9.3. Precedence .................................................................................................................... 2.10. IDENT Protocol Support ..................................................................................................... 3. ARGUMENTS ............................................................................................................................... 7 7 7 7 8 8 8 10 10 10 10 10 10 10 11 11 11 11 13 13 13 13 13 14 14 14 14 14 15 16 16 17 18 18 18 18 19 19 19 19 19 20
SMM:08-4
3.1. Queue Interval ....................................................................................................................... 3.2. Daemon Mode ....................................................................................................................... 3.3. Forcing the Queue ................................................................................................................. 3.4. Debugging ............................................................................................................................. 3.5. Changing the Values of Options ............................................................................................ 3.6. Trying a Different Conguration File ................................................................................... 3.7. Logging Trafc ...................................................................................................................... 3.8. Testing Conguration Files ................................................................................................... 3.9. Persistent Host Status Information ........................................................................................ 4. TUNING ......................................................................................................................................... 4.1. Timeouts ................................................................................................................................ 4.1.1. Queue interval .............................................................................................................. 4.1.2. Read timeouts ............................................................................................................... 4.1.3. Message timeouts ......................................................................................................... 4.2. Forking During Queue Runs ................................................................................................. 4.3. Queue Priorities ..................................................................................................................... 4.4. Load Limiting ........................................................................................................................ 4.5. Delivery Mode ....................................................................................................................... 4.6. Log Level ............................................................................................................................... 4.7. File Modes ............................................................................................................................. 4.7.1. To suid or not to suid? ................................................................................................. 4.7.2. Turning off security checks .......................................................................................... 4.8. Connection Caching .............................................................................................................. 4.9. Name Server Access .............................................................................................................. 4.10. Moving the Per-User Forward Files .................................................................................... 4.11. Free Space ........................................................................................................................... 4.12. Maximum Message Size ..................................................................................................... 4.13. Privacy Flags ....................................................................................................................... 4.14. Send to Me Too ................................................................................................................... 5. THE WHOLE SCOOP ON THE CONFIGURATION FILE ........................................................ 5.1. R and S Rewriting Rules .................................................................................................. 5.1.1. The left hand side ......................................................................................................... 5.1.2. The right hand side ....................................................................................................... 5.1.3. Semantics of rewriting rule sets ................................................................................... 5.1.4. Ruleset hooks ............................................................................................................... 5.1.4.1. check_relay .......................................................................................................... 5.1.4.2. check_mail .......................................................................................................... 5.1.4.3. check_rcpt ........................................................................................................... 5.1.4.4. check_compat ...................................................................................................... 5.1.4.5. check_eoh ............................................................................................................ 5.1.4.6. check_etrn ........................................................................................................... 5.1.4.7. check_expn .......................................................................................................... 5.1.4.8. check_vrfy ........................................................................................................... 5.1.4.9. trust_auth .............................................................................................................
20 20 20 21 21 21 22 22 23 23 23 23 23 25 26 26 26 27 27 28 28 28 30 30 31 32 32 32 32 32 33 33 34 35 36 36 36 36 36 36 37 37 37 37
SMM:08-5
5.1.4.10. tls_client ............................................................................................................ 5.1.4.11. tls_server ........................................................................................................... 5.1.5. IPC mailers ................................................................................................................... 5.2. D Dene Macro ................................................................................................................ 5.3. C and F Dene Classes ..................................................................................................... 5.4. M Dene Mailer ............................................................................................................... 5.5. H Dene Header ............................................................................................................... 5.6. O Set Option ..................................................................................................................... 5.7. P Precedence Denitions .................................................................................................. 5.8. V Conguration Version Level ......................................................................................... 5.9. K Key File Declaration ..................................................................................................... 5.10. The User Database .............................................................................................................. 5.10.1. Structure of the user database ..................................................................................... 5.10.2. User database semantics ............................................................................................. 5.10.3. Creating the database24 ............................................................................................... 6. OTHER CONFIGURATION ......................................................................................................... 6.1. Parameters in devtools/OS/$oscf ........................................................................................... 6.2. Parameters in sendmail/conf.h .............................................................................................. 6.3. Conguration in sendmail/conf.c .......................................................................................... 6.3.1. Built-in Header Semantics ........................................................................................... 6.3.2. Restricting Use of Email .............................................................................................. 6.3.3. New Database Map Classes ......................................................................................... 6.3.4. Queueing Function ....................................................................................................... 6.3.5. Refusing Incoming SMTP Connections ....................................................................... 6.3.6. Load Average Computation .......................................................................................... 6.4. Conguration in sendmail/daemon.c ..................................................................................... 6.5. Certicates for STARTTLS ................................................................................................... 6.6. PRNG for STARTTLS .......................................................................................................... 7. ACKNOWLEDGEMENTS ............................................................................................................ Appendix A. COMMAND LINE FLAGS ......................................................................................... Appendix B. QUEUE FILE FORMATS ............................................................................................ Appendix C. SUMMARY OF SUPPORT FILES ..............................................................................
37 38 38 38 43 45 49 50 63 63 64 70 70 71 71 71 72 72 75 75 77 77 78 78 78 79 79 79 79 81 83 86
SMM:08-6
This page intentionally left blank; replace it with a blank sheet for double-sided output.