Chapter 5


Sendmail

5.1 ABSTRACT

sendmail implements a general purpose internetwork mail routing facility under the UNIX operating system. It is not tied to any one transport protocol -- its function can be compared to a crossbar switch that relays messages from one domain to another. In the process, it can perform 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 configuration file.

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.

Home


5.2 NORMAL OPERATIONS

5.2.1 The System Log

The system log is supported by the syslogd(1M) program. All messages from sendmail are logged under the LOG_MAIL facility (except on Ultrix, which does not support facilities in the syslog).

5.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 message (This format may vary slightly if your vendor has changed the syntax). Most messages are a sequence of name=value pairs.

The two most common lines are logged when a message is processed. The first logs the receipt of a message; there will be exactly one of these per message. Some fields may be omitted if they do not contain interesting information. Fields are:

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: Not all fields are present in all messages; for example, the relay is not listed for local deliveries.
5.2.1.2 LEVELS

If you have syslogd(1M) 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 11-64 are reserved for verbose information that some sites might want.

A complete description of the log levels is given in Section 5.4.6.

Home


5.2.2 Dumping State

You can ask sendmail to log a dump of the open files and the connection cache by sending it a SIGUSR1 signal. The results are logged at LOG_DEBUG priority.

5.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. Howev er, you may find 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 find performance unacceptably bad in the meantime.

5.2.3.1 PRINTING THE QUEUE

The contents of the queue can be printed using the mailq command (or by specifying the -bp flag to sendmail):

mailq
This will produce a listing of the queue id's, the size of the message, the date the message entered the queue, and the sender and recipients.

Home


5.2.3.2 FORCING THE QUEUE

sendmail should run the queue automatically at intervals. 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 first checks to see if the job is locked. If so, it ignores the job.

There is no attempt to ensure 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 exceptionally long 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 general way to resolve this.

In some cases, you may find 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 fixed by moving the queue to a temporary location 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/ucblib/sendmail -oQ/var/spool/omqueue -q
The -oQ flag specifies an alternate queue directory and the -q flag says to just run every job in the queue. If you wish, you can use the -v flag to watch what is going on.

When the queue is finally emptied, you can remove the directory:

rmdir /var/spool/omqueue

Home


5.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 will cause hosts that are skipped because another sendmail instance is talking to it to be tried again soon.

The disk based host information is stored in a subdirectory of of the mqueue directory called .hoststat (this is the usual value of the HostStatusDirectory option; it can, of course, go anywhere you like in your filesystem). Removing this directory and its subdirectories has an effect similar to the purgestat command and is completely safe. The information in these directories can be perused with the hoststat command, which will 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 time-outs. 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 purged 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.

Home


5.2.5 The Alias Database

The alias database exists in two forms. One is a text form, maintained in the file /var/ucblib/aliases. The aliases are of the form

name: name1, name2, ...
Only local names may be aliased; e.g.,
eric@prep.ai.MIT.EDU: eric@CS.Berkeley.EDU
will not have the desired effect (except on prep.ai.MIT.EDU, and they probably don't want me. (Actually, any mailer that has the 'A' mailer flag set will permit aliasing; this is normally limited to the local mailer.) Aliases may be continued by starting any continuation lines with a space or a tab. Blank lines and lines beginning with a sharp sign ("#") are comments.

The second form is processed by the ndbm(3X)(The gdbm package probably works as well) library. This form is in the files /var/ucblib/aliases.dir and /var/ucblib/aliases.pag. 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

OAswitch:aliases
is always added as the first alias entry; also, the first alias file name without a class (e.g., without "nis:" on the front) will be used as the name of the file for a "files" entry in the aliases switch. For example, if the configuration file contains
OA/var/ucblib/aliases
and the service switch contains
aliases nis files
then aliases will first be searched in the NIS database, then in /var/ucblib/aliases.

You can also use NIS-based alias files. For example, the specification:

OA/var/ucblib/aliases
OAnis:mail.aliases@my.nis.domain
will first search the /var/ucblib/aliases file and then the map named "mail.aliases" in "my.nis.domain".

Home


5.2.5.1 REBUILDING THE ALIAS DATABASE

The DBM version of the database may be rebuilt explicitly by executing the command

newaliases

This is equivalent to giving sendmail the -bi flag:

/usr/ucblib/sendmail -bi

If the RebuildAliases (old D) option is specified in the configuration, 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 files; if it might take more than the rebuild time-out (option AliasWait, old a, which is normally five minutes) to rebuild the database, there is a chance that several processes will start the rebuild process simultaneously.

If you have multiple alias databases specified, the -bi flag rebuilds all the database types it understands (for example, it can rebuild NDBM databases but not NIS databases).

If you change sendmail version from 5 to 8, you have to rebuild alias database.

5.2.5.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 and leaving a partially rebuilt database. Second, it locks the database source file during the rebuild -- but that may not work over NFS or if the file is unwriteable. 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 ensure that this entry exists. (The AliasWait option is required in the configuration for this action to occur. This should normally be specified.)
5.2.5.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 modified. 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.

Home


5.2.6 Per-User Forwarding (.forward Files)

As an alternative to the alias database, any user may put a file with the name ".forward" in his or her home directory. If this file exists, sendmail redirects mail for that user to the list of addresses listed in the .forward file. For example, if the home directory for user "mckusick" has a .forward file with contents:

mckusick@ernie
kirk@calder
then any mail arriving for "mckusick" will be redirected to the specified accounts.

Actually, the configuration file defines a sequence of filenames to check. By default, this is the user's .forward file, but can be defined to be more general using the J 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.

5.2.7 Special Header Lines

Several header lines have special interpretations defined by the configuration file. Others have interpretations built into sendmail that cannot be changed without changing the code. These built-ins are described here.

5.2.7.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 didn't 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 officially discouraged and will be phased out in future releases.

5.2.7.2 APPARENTLY-TO:

RFC 822 requires at least one recipient field (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 "Apparently To:" header line for any recipients it is aware of. This is not put in as a standard recipient line to warn any recipients that the list is not complete.

The Apparently-To: header is non-standard and is not advised.

5.2.7.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 configured to change the message time-out values.

Home


5.2.8 IDENT Protocol Support

sendmail supports the IDENT protocol as defined in RFC 1413. Although this enhances identification 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 identifier the user wants. Likewise, if the host has been compromised the information returned may be completely erroneous and misleading.

The Identification 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 any purpose other than auditing is strongly discouraged. Specifically, using Identification 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 breach of normal host security.

An Identification server may reveal information about users, entities, objects or processes which normally would be considered private. An Identification server provides a service which is akin to the CallerID services provided by some phone companies. Many of the same privacy considerations and arguments that apply to the CallerID service also apply to Identification. If you wouldn't run a "finger" 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 close almost immediately. If this is true or if you do not want to use IDENT, you should set the IDENT time-out to zero; this will disable the IDENT protocol.

5.2.9 Internet Domain Name Server

To use domain name service, install /usr/ucblib/sendmail.mx in place of /usr/ucblib/sendmail on the mailhost. Each machine running sendmail.mx must have either /etc/resolv.conf or /etc/named.boot set up properly to allow name resolution or at least a caching server.

Home


5.3 ARGUMENTS

The complete list of arguments to sendmail is described in detail in Section 5.6. Some important arguments are described here.

5.3.1 Queue Interval

The amount of time between forking a process to run through the queue is defined by the -q flag. 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 defines 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 doesn't make sense if you use "queue-only" mode).

5.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/inet/rc.inetcmd file using the -bd flag. The -bd flag and the -q flag may be combined in one call:

/usr/ucblib/sendmail -bd -q30m
An alternative approach is to invoke sendmail from inetd(1M) (use the -bs flag 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 configuration file has to be re-read on every message that comes in. If you do this, you still need to have a sendmail running to flush the queue:
/usr/ucblib/sendmail -q30m

5.3.3 Forcing the Queue

In some cases you may find that the queue has gotten clogged for some reason. You can force a queue run using the -q flag (with no value). It is entertaining to use the -v flag (verbose) when this is done to watch what happens:

/usr/ucblib/sendmail -q -v
You can also limit the jobs to those with a particular queue identifier, sender, or recipient using one of the queue modifiers. 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 identifiers.

5.3.4 Debugging

There are a fairly large number of debug flags built into sendmail. Each debug flag has a number and a level, where a higher level 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 wouldn't normally want to see them except in the debugging process. Debug flags are set using the -d option; the syntax is:

debug-flag:-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,
-d12Set flag 12 to level 1
-d12.3Set flag 12 to level 3
-d3-17Set flags 3 through 17 to level 1
-d3-17.4Set flags 3 through 17 to level 4
A complete list of the available debug flags is beyond the scope of this document Look at the code for the available debug flags, you will have to look at the source code.

Home


5.3.5 Changing the Values of Options

Options can be overridden using the -o or -O command line flags. For example,

/usr/ucblib/sendmail -oT2m
sets the T (time-out) option to two minutes for this run only; the equivalent line using the long option name is
/usr/ucblib/sendmail -OTimeout.queuereturn=2m
Some options have security implications. sendmail allows you to set these, but relinquishes its setuid root permissions thereafter. (That is, it sets its effective uid to the real uid; thus, if you are executing as root, as from root's crontab file, or during system startup, the root permissions will still be honored.)

5.3.6 Trying a Different Configuration File

An alternative configuration file can be specified using the -C flag; for example,

/usr/ucblib/sendmail -Ctest.cf -oQ/tmp/mqueue
uses the configuration file test.cf instead of the default /var/ucblib/sendmail.cf. If the -C flag has no value it defaults to sendmail.cf in the current directory.

sendmail gives up its setuid root permissions when you use this flag, so it is common to use a publicly writeable directory (such as /tmp) as the spool directory (QueueDirectory or Q option) while testing.

5.3.7 Logging Traffic

Many SMTP implementations do not fully implement the protocol. For example, some PC-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 traffic logging using the -X flag. For example,

/usr/ucblib/sendmail -X /tmp/traffic -bd
will log all traffic in the file /tmp/traffic.

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 traffic in and out of sendmail, including the incoming SMTP traffic, will be logged in this file.

Home


5.3.8 Testing Configuration Files

When you build a configuration 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 configuration file "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, finally 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
first 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" flag 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 bruce@broadcast.sony.com
This version requires that you use:
3,0 bruce@broadcast.sony.com
As of version 8.7, some other syntaxes are available in test mode:

5.3.9 Persistent Host Status Information

When HostStatusDirectory is enabled, information about the status of hosts is maintained on disk and can 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 flushed 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.

Home


5.4 TUNING

There are a number of configuration parameters you may want to change, depending on the requirements of your site. Most of these are set using an option in the configuration file. For example, the line "O Timeout.queuereturn=5d" sets option "Timeout.queuereturn" to the value "5d" (five days).

Most of these options have appropriate defaults for the amjority of sites. However, sites having very high mail loads may find they need to tune them as appropriate for their mail load. In particular, sites receiving a large number of small messages delivered to many recipients may 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 recognized, most new options do not have short equivalents.

This section describes only the options you are most likely to want to modify; read Section 5.5 for more details.

5.4.1 Time-Outs

All time intervals are set using a scaled syntax. For example, "10m" represents ten minutes, whereas "2h30m" represents 2.5 hours. The full set of scales is:

sseconds
mminutes
hhours
ddays
wweeks
5.4.1.1 QUEUE INTERVAL

The argument to the -q flag specifies how often a sub-daemon will run the queue. This is typically set to between fifteen minutes and one hour. RFC 1123 section 5.3.1.1 recommends that this be at least 30 minutes.

Home


5.4.1.2 READ TIME-OUTS

Time-outs 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:

If no suboption is specified, all the time-outs marked with # are set to the indicated value. This is done for compatibility with old configuration files.

Home


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 time-outs; hence, versions of sendmail prior to version 8.1 did not guarantee prompt replies to messages. In particular, an "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 five minutes. (This verification includes looking up every address with the name server; this involves network delays, and can in some cases can be considerable.) I recommend a one-hour time-out -- since a communications failure during the RCPT phase is rare, a long time-out 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
set the server SMTP command time-out to 25 minutes and the input data block time-out to three hours.
5.4.1.3 MESSAGE TIME-OUTS

After sitting in the queue for a few days, a message will time out. This is to ensure that the sender is aware of the inability to send a message. The time-out is typically set to five 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 wouldn't want to do this because it wouldn't be an unusual event). These time-outs are set using the Timeout.queuereturn and Timeout.queue warn options in the configuration file (previously both were set using the T option).

Since these options are global, and since you cannot know a priori how long another host outside your domain will be down, a five-day time-out is recommended. This allows a recipient to fix 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 4-5 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 time-outs are separated by a slash. For example, the line

OT5d/4h
causes email to fail after five 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.

Home


5.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 cannot use connection caching.

5.4.3 Queue Priorities

Every message is assigned a priority when it is first 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:" field in their message; the value of this field is looked up in the P lines of the configuration file. 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 configuration file 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.

Home


5.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 if: 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 defines a load average at which sendmail will refuse to accept network connections. Locally generated mail (including incoming UUCP mail) is still accepted.

5.4.5 Delivery Mode

There are a number of delivery modes that sendmail can operate in, set by the DeliveryMode (d) configuration option. These modes specify how quickly mail will be delivered. Legal modes are: 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 files upon initial receipt of the mail. This speeds up the response to RCPT commands. Mode "i" cannot be used by the SMTP server.

Home


5.4.6 Log Level

The level of logging can be set for sendmail. The default using a standard configuration table is level 9. The levels are as follows:

Additionally, values above 64 are reserved for extremely verbose debugging output. No normal site would ever set these.

5.4.7 File Modes

The modes used for files depend on what functionality you want and the level of security you require.

5.4.7.1 TO SUID OR NOT TO SUID?

sendmail can safely be made setuid to root. At the point where it is about to exec(2) a mailer, it checks to see if the userid is zero; if so, it resets the userid and groupid to a default (set by the u and g options). (This can be overridden by setting the S flag to the mailer for mailers that are trusted and must be called as root.) However, this will cause mail processing to be accounted to root rather than to the user sending the mail.

If you don't make sendmail setuid to root, it will still run but you lose a lot of functionality and a lot of privacy, since you'll 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 fix the privacy problems but not the functionality issues. Also, this isn't a guarantee of security: for example, root occasionally sends mail, and the daemon often runs as root.

5.4.7.2 SHOULD MY ALIAS DATABASE BE WRITEABLE?

At Berkeley we have the alias database (/var/ucblib/aliases*) mode 644. While this is not as flexible as if the database were more (e.g., 666), it avoids potential security problems with a globally writeable database.

The database that sendmail actually used is represented by the two files aliases.dir and aliases.pag (both in /var/ucblib) (or aliases.db if you are running with the new Berkeley database primitives). The mode on these files should match the mode on /var/ucblib/aliases. If aliases is writeable and the DBM files (aliases.dir and aliases.pag) are not, users will be unable to reflect their desired changes through to the actual database. However, if aliases is read-only and the DBM files are writeable, a slightly sophisticated user can arrange to steal mail anyway.

If your DBM files are not writeable by the world or you do not have auto-rebuild enabled (with the AutoRebuildAliases option), then you must be careful to reconstruct the alias database each time you change the text version:

newaliases
If this step is ignored or forgotten any intended changes will also be ignored or forgotten.

Home


5.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 first searched. If an open connection is found, it is probed to see if it is still active by sending an 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 defines 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 specifies the maximum time that any cached con nection 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 five minutes.

Home


5.4.9 Name Server Access

The ResolverOptions (I) option allows you to tweak name server options. The command line takes a series of flags as documented in resolver(3N) (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 flags on and all others off. You can also include "HasWildcardMX" to specify that there is a wild card MX record matching your domain; this turns off MX matching when canonifying names, which can lead to inappropriate canonifications.

Version level 1 configurations turn DNSRCH and DEFNAMES off when doing delivery lookups, but leave them on everywhere else. Version 8 of sendmail ignores them when doing canonification lookups (that is, when using $[ ... $]), and always does the search. If you don't want to do automatic name extension, don't 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 unmodified name first. If that fails, it tries the reduced search path, and lastly tries the unmodified 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 finds 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.

Home


5.4.10 Moving the Per-User Forward Files

Some sites mount each user's home directory from a local disk on their workstation, so that local access is fast. However, the result is that .forward file lookups are slow. In some cases, mail can even be delivered on machines inappropriately because of a file 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 files. For example, the config file line

O ForwardPath=/var/forward/$u:$z/.forward.$w
would first look for a file with the same name as the user's login in /var/forward; if that is not found (or is inaccessible) the file ".forward.machinename" in the user's home directory is searched. A 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 files mode 644.

5.4.11 Free Space

On systems that have one of the system calls in the statfs(2) family , you can specify a minimum number of free blocks on the queue filesystem using the Min FreeBlocks (b) option. If there are fewer than the indicated number of blocks free on the filesystem 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 difficulty.

Home


5.4.12 Maximum Message Size

To avoid overflowing 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.

5.4.13 Privacy Flags

The PrivacyOptions (p) option allows you to set certain "privacy" flags. Actually, many of them don't give you any extra privacy. Instead, they require 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 flag names; the final privacy is the inclusive or of those flags. 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 flags are detailed in Section 5.5.6.

5.4.14 Send to Me Too

Normally, sendmail deletes the (envelope) sender from any list expansions. For example, if "matt" sends to a list that contains "matt" as one of the members he won't get a copy of the message. If the -m (me too) command line flag, or if the MeToo (m) option is set in the configuration file, this behavior is suppressed. Some sites like to run the SMTP daemon with -m.

Home


5.5 THE WHOLE SCOOP ON THE CONFIGURATION FILE

This section describes the configuration file in detail.

There is one point that should be made clear: since the configuration file is parsed every time sendmail starts up. the syntax of the configuration file is optimized for this purpose (easy parsing by the system, as opposed to easy reading by the operator, is the goal.) On the "future project" list is a configuration-file compiler.

The configuration file is organized as a series of lines, each of which begins with a single character defining 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 defined in many places). Blank lines and lines beginning with a sharp symbol ('#') are comments.

5.5.1 R and S -- Rewriting Rules

The core of address parsing is 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 specific semantics. Other rewriting sets do not have specifically assigned semantics, and may be referenced by the mailer definitions 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 definition.
Rlhs rhs comments
The fields must be separated by at least one tab character; there may be embedded spaces in the fields. 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 configuration file is read. Expansions of the form $&x are performed at run time using a somewhat less general algorithm. This is intended only for referencing internally defined macros such as $h that are changed at runtime.

Home


5.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:

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: 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.

Home


5.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:

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 name. (This is actually completely equivalent to $(host hostname$). In particular, a $: default can be used.) 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 specified 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 final value of ruleset n then becomes the substitution for this rule. The $> syntax can only be used at the beginning of the right-hand side; it can be only be preceded by $@ or $:.

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 specifies the {mailer, host, user} 3-tuple necessary to direct the mailer. If the mailer is local the host part may be omitted. (You may want to use it for special "per user" extensions. For example, in the address "jgm+f oo@CMU.EDU"; the "+foo" part is not part of the user name, and is passed to the local mailer for local use.) The mailer must be a single word, but the host and user may be multi-part. If the mailer is the built-in IPC mailer, the host may be a colon-separated list of hosts that are searched in order for the first working address (exactly like MX records). The user is later rewritten by the mailer-specific envelope rewriting set and assigned to the $u macro. As a special case, if the mailer specified has the F=@ flag specified and the first character of the $: value is "@", the "@" is stripped off, and a flag is set in the address descriptor that causes sendmail to not do ruleset 5 processing.

Normally, a rule that matches is retried, that is, the rule loops until it fails. An RHS may also be preceded by a $@ or a $: to change this behavior. A $@ prefix causes the ruleset to return with the remainder of the RHS as the value. A $: prefix causes the rule to terminate immediately, but the ruleset to continue; this can be used to avoid continued application of a rule. The prefix is stripped before continuing.

The $@ and $: prefixes may precede a $> spec; for example:

R$+ $: $>7 $1
matches anything, passes that to ruleset seven, and continues; the $: is necessary to avoid an infinite loop.

Substitution occurs in the order described, that is, parameters from the LHS are substi tuted, hostnames are canonicalized, "subroutines" are called, and finally $#, $@, and $: are processed.

Home


5.5.1.3 SEMANTICS OF REWRITING RULE SETS

There are five rewriting sets that have specific semantics. Four of these are related, as depicted by Figure 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 specified, then the host-domain-spec may be appended (box "D" in Figure 1) from the sender address (if the C flag is set in the mailer definition 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, user} triple. The mailer must be defined in the mailer definitions from the configuration file. The host is defined into the $h macro for use in the argv expansion of the specified mailer.

Rulesets one and two are applied to all sender and recipient addresses respectively. They are applied before any specification in the mailer definition. They must never resolve.

Ruleset four is applied to all addresses in the message. It is typically used to translate internal to external form.

Figure 5-1 Rewriting Set Semantics

In addition, ruleset 5 is applied to all local addresses (specifically, those that resolve to a mailer with the 'F=5' flag set) that do not have aliases. This allows a last minute hook for local names.

Home


5.5.1.4 RULESET HOOKS

A few extra rulesets are defined as "hooks" that can be defined 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.

5.5.1.4.1 check_relay

The check_relay ruleset is called after a connection is accepted. 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.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.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.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.

Home


5.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 configuration line. The host name passed after "$@" has MX expansion performed; this looks the name up in DNS to find 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 a TCP/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 final 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 firewall 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.5.2 D -- Define Macro

Macros are named with a single character or with a word in {braces}. Single character names may be selected from the entire ASCII set, but user-defined macros should be selected from the set of uppercase letters only. Lowercase letters and special symbols are used internally. Long names beginning with a lowercase letter or a punctuation character are reserved for use by sendmail, so user-defined long macro names should begin with an uppercase letter.

The syntax for macro definitions 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 configuration file is read, except in M lines. The special construct $&x can be used in R lines to get deferred interpolation.

Conditionals can be specified using the syntax:

$?x text1 $| text2 $.
This interpolates text1 if the macro $x is set, and text2 otherwise. The "else" ($|) clause may be omitted.

Lowercase 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. Uppercase names (that is, $A through $Z) are specifically reserved for configuration file authors.

Home


The following macros are defined and/or used internally by sendmail for interpolation into argv's for mailers or for other contexts. The ones marked # are information passed into sendmail. (As of version 8.6, all of these macros have reasonable defaults. Previous versions required that they be defined.) 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:

Home


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) for mat.

The macros $w, $j, and $m are set to the identity of this host. sendmail tries to find the fully qualified name of the host if at all possible; it does this by calling gethostname(2) to get the current hostname and then passing that to gethostbyname(3N) which is supposed to return the canonical version of that host name (for example, on some systems gethostname might return "foo" which would be mapped to "foo.bar.com" by gethostbyname). Assuming this is successful, $j is set to the fully qualified name and $m is set to the domain part of the name (everything after the first dot). The $w macro is set to the first word (everything before the first dot) if you have a level 5 or higher configuration file; otherwise, it is set to the same value as $j. If the canonification is not successful, it is imperative that the config file set $j to the fully qualified domain name (older versions of sendmail didn't pre-define $j at all, so up until 8.6, config files always had to define $j).

The $f macro is the id of the sender as originally determined; when mailing to a specific host the $g macro is set to the address of the sender relative to the recipient. For example, if I send to "bollard@matisse.CS.Berkeley.EDU" from the machine "vangogh.CS.Berkeley.EDU" the $f macro will be "eric" and the $g macro will be "eric@vangogh.CS.Berkeley.EDU."

The $x macro is set to the full name of the sender. This can be determined in several ways. It can be passed as flag to sendmail. It can be defined 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 field 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 file.

When sending, the $h, $u, and $z macros get set to the host, user, and home directory (if local) of the recipient. The first two are set from the $@ and $: parts of the rewriting rules, respectively.

The $p and $t macros are used to create unique strings (e.g., for the "Message-Id:" field). 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 nor mally put in timestamps and has been proven extremely useful for debugging.

The $c field is set to the "hop count," i.e., the number of times this message has been processed. This can be determined by the -h flag on the command line or by counting the timestamps in the message.

The $r and $s fields are set to the protocol used to communicate with sendmail and the sending hostname. They can be set together using the -p command line flag or separately using the -M or -oM flags.

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!).

Home


5.5.3 C and F -- Define Classes

Classes of phrases may be defined to match on the left-hand side of rewriting rules, where a "phrase" is a sequence of characters that do 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 defined directly in the configuration file or read in from another file. Classes are named as a single letter or a word in {braces}. Class names beginning with lowercase letters and special characters are reserved for system use. Classes defined in config files may be given names from the set of uppercase letters for short names or beginning with an uppercase letter for long names.

The syntax is:

Cc phrase1 phrase2...
Fc file
The first form defines the class c to match any of the named words. It is permissible to split them among multiple lines; for example, the two forms:
CHmonet ucbmonet
and
CHmonet
CHucbmonet
are equivalent. The "F" form reads the elements of the class c from the named file.

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:

sendmail can be compiled to allow a scanf(3S) string on the F line. This lets you do simplistic parsing of text files. For example, to read all the user names in your system /etc/passwd file into a class, use

FL/etc/passwd %[^:]
which reads every line up to the first colon.

Home


5.5.4 M -- Define Mailer

Programs and interfaces to mailers are defined in this line. The format is:

Mname, {field=value }*
where name is the name of the mailer (used internally only) and the "field=name" pairs define attributes of the mailer. Fields are:
PathThe pathname of the mailer
FlagsSpecial flags for this mailer
SenderRewriting set(s) for sender addresses
RecipientRewriting set(s) for recipient addresses
ArgvAn argument vector to pass to this mailer
EolThe end-of-line string for this mailer
MaxsizeThe maximum message length to this mailer
LinelimitThe maximum line length in the message body
DirectoryThe working directory for the mailer
UseridThe default user and group id to run as
NiceThe nice(2) increment for the mailer
CharsetThe default character set for 8-bit characters
TypeThe MTS type information (used for error messages)
Only the first character of the field name is checked.

Home


The following flags may be set in the mailer description. Any other flags 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 conventionally used to correlate to the flags portion of the H line. Flags marked with ## apply to the mailers for the sender address rather than the usual recipient mailers.

Configuration files prior to level 6 assume the 'A', 'w', '5', ':', '|', '/', and '@' options on the mailer named "local".

Home


The mailer with the special name "error" can be used to generate a user error. The (optional) host field is an exit status to be returned, and the user field 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 specified 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 named "local" must be defined in every configuration file. This is used to deliver local mail, and is treated specially in several ways. Additionally, three other mailers named "prog", "*file*", and "*include*" may be defined to tune the delivery of messages to programs, files, and :include: lists respectively. They default to:

Mprog, P=/bin/sh, F=lsD, A=sh -c $u
M*file*, P=/dev/null, F=lsDFMPEu, A=FILE
M*include*, P=/dev/null, F=su, A=INCLUDE
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 first rewriting set is applied to envelope addresses and the second is applied to headers.

The Directory is actually a colon-separated path of directories to try. For example, the definition "D=$z:/" first tries to execute in the recipient's home directory; if that is not available, it tries to execute in the root of the filesystem. 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 specifies the default user and group id to run as, overriding the DefaultUser option (q.v.). If the S mailer flag is also specified, this is the user and group to run as in all circumstances. 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 files respectively. If only a symbolic user name is specified, the group id in the passwd file for that user is used as the group id.

The Charset field 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 field applies to the sender's mailer, not the recipient's 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= field for the local network mailer, not that of the external network mailer.

The Type= field sets the type information used in MIME error messages as defined 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".

Home


5.5.5 H -- Define Header

The format of the header lines that sendmail inserts into the message are defined by the H line. The syntax of this line is:

H[?mflags?]hname: htemplate
Continuation lines in this spec are reflected directly into the outgoing message. The htemplate is macro expanded before insertion into the message. If the mflags (surrounded by question marks) are specified, at least one of the specified flags must be stated in the mailer definition for this header to be automatically output. If one of these headers is in the input it is reflected to the output regardless of these flags.

Some headers have special semantics that will be described later.

5.5.6 O -- Set Option

There are a number of global options that can be set from a configuration file. Options are represented by full words; some are also representable as single characters for backward 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.

Home


The options supported (with the old, one character names in brackets) are:

AliasFile=spec, spec, ...
[A] Specify possible alias file(s). Each spec should be in the format "class: file" 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 file types, for backward compatibility), "dbm" (if NDBM is specified), "stab" (internal symbol table -- not normally used unless you have no other database lookup), or "nis" (if NIS is specified). 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 time-out 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 don't 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.

AutoRebuildAliases
[D] If set, rebuild the alias database if necessary and possible. If this option is not set, sendmail will never rebuild the alias database unless explicitly requested using -bi. Not recommended -- can cause thrashing.

BlankSub=c
[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).

CheckAliases
[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 recipients.

ClassFactor=fact
[z] The indicated factor is multiplied by the message class (determined by the Precedence: field in the user header and the P lines in the configuration file) and subtracted from the priority. Thus, messages with a higher Priority: will be favored. Defaults to 1800.

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 an 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 configuration version level is less than 6 (for backward compatibility). However, it must be off for full compatibility with RFC 822.

Home


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 invoca tion 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 file 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. This value should be small (on the order of ten minutes). Before sendmail uses a cached connection, it always sends an 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 five minutes.

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 flatten out peaks and allow the load average checking to cut in. Defaults to zero (no limits).

DaemonPortOptions=options
[O] Set server SMTP options. The options are key=value pairs. Known keys are:
PortName/number of listening port (defaults to "smtp")
AddrAddress mask (defaults INADDR_ANY)
FamilyAddress family (defaults to INET)
ListenSize of listen queue (defaults to 5)
SndBufSizeSize of TCP send buffer
RcvBufSizeSize of TCP receive buffer
The Address mask may be a numeric address in dot notation or a network name.

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= field 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.

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 file for that user is used as the default group. Both user and group may be numeric. Mailers without the S flag in the mailer definition will run as this user. Defaults to 1:1. The value can also be given as a symbolic user name (the old g option has been combined into the DefaultUser option).

DeliveryMode=x
[d] Deliver in mode x. Leg al modes are:
iDeliver interactively (synchronously)
bDeliver in background (asynchronously)
qJust queue the message (deliver during queue run)
dDefer delivery and all map lookups (deliver during queue run)
Defaults to "b" if no option is specified, "i" if it is specified but given no argument (i.e., "Od" is equivalent to "Odi"). The -v command line flag sets this to i.

Home


DialDelay=sleeptime
[no short name] Dial-on-demand network connections can see time-outs 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 first attempt, 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 five second delay. Defaults to zero (no retry).

DontExpandCnames
[no short name] Current standards dictate 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 canonification ($[ ... $] 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(3C) 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 file), which will make file access permissions somewhat more restrictive. Has no effect on systems that don't have group lists.

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 first address in the route, even if later addresses are known. This may be useful if you are caught behind a firewall.

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. 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 flag, 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-8BIT MIME mailer. The possible actions are:
sReject undeclared 8-bit data ("strict")
mConvert undeclared 8-bit data to MIME ("mime")
pPass undeclared 8-bit data ("pass")
In all cases properly declared 8BITMIME data will be converted to 7BIT as needed.

Home


ErrorHeader=file-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 file containing a message (this is the recommended setting). Otherwise, it is a literal message. The error file 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 file 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:
pPrint error messages (default)
qNo messages, just give exit status
mMail back errors
wWrite back errors (mail if user not logged in)
eMail back errors and give zero exit stat always
FallbackMXhost=fallbackhost
[V] If specified, the fallbackhost acts like a very low priority MX on every host. This is intended to be used by sites with poor network connectivity.

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 files. The default is "$z/.for ward". Some sites that use the automounter may prefer to change this to "/var/forward/$u" to search a file 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 first file it can successfully and safely open. For example, "/var/for ward/$u:$z/.forward" will search first in /var/forward/username and then in ~user name/.forward (but only if the first file does not exist).

HelpFile=file
[H] Specify the help file for SMTP.

HoldExpensive
[c] If an outgoing mailer is marked as being expensive, don't connect immediately. This requires that queueing be compiled in, since it will depend on a queue run process to actually send the mail.

Home


HostsFile=path
[no short name] The path to the hosts database, normally "/etc/hosts". In particular, this file is never used when looking up host addresses; that is under the control of the system gethostby name(3N) routine.

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 path name; 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.

LogLevel=n
[L] Set the default log level to n. Defaults to 9.

Mx value
[no long version] Set the macro x to value. This is intended only for use from the command line. The -M flag is preferred.

MatchGECOS
[G] Allow fuzzy matching on the GECOS field. If this flag 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 file for a matching entry in the GECOS field. This also requires that MATCHGECOS be turned on during compilation. This option is not recommended.

MaxDaemonChildren=N
[no short name] If set, sendmail will refuse connections when it has more than N children processing incoming mail. 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.

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.

MaxHostStatAge=age
[no short name] Not yet implemented. This option specifies how long host status information will be retained. For example, if a host is found to be down, connec \tions to that host will not be retried for this interval. The units default to minutes.

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.

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 first 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.

Home


MeToo
[m] Send to me too, even if I am in an alias expansion.

MinFreeBlocks=N
[b] Insist on at least N blocks free on the filesystem that holds the queue files before accepting email via SMTP. If there is insufficient space sendmail gives a 452 response to the MAIL command. This invites the sender to try again later.

MinQueueAge=age
[no short name] Don't 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 backward compatibility with old sendmails). It can be None to pass the message on unmodified, which violates the protocol, Add-To to add a To: header with any recipients it can find in the envelope (which might expose Bcc: recipients), Add-Apparently-To to add an Apparently-To: header (this is only for backward compatibility and is officially discouraged.), Add-To-Undisclosed to add a header "To: undisclosed recipients:;" 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 (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 flag 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.

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. 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. Defaults to no postmaster copies.

Home


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:
publicAllow open access
needmailheloInsist on HELO or EHLO command before MAIL
needexpnheloInsist on HELO or EHLO command before EXPN
noexpnDisallow EXPN entirely
needvrfyheloInsist on HELO or EHLO command before VRFY
novrfyDisallow VRFY entirely
restrictmailqRestrict mailq command
restrictqrunRestrict -q command line flag
noreceiptsDon't return success DSNs
goawayDisallow essentially all SMTP status queries
authwarningsPut X-Authentication-Warning: headers in messages
The "goaway" pseudo-flag sets all flags except "restrictmailq" and "restrictqrun". 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 a non-standard queue directory.

QueueDirectory=dir
[Q] Use the named dir as the queue directory.

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., don't try to send them).

QueueSortOrder=algorithm
[no short name] Sets the algorithm used for sorting the queue. Only the first character of the value is used. Legal values are "host" (to order by the name of the first host name of the first recipient), "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 shouldn't be used on slow network links. 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 "Queue Timeout" form.

Home


ResolverOptions=options
[I] Set resolver options. Values can be set using +flag and cleared using -flag; the flags can be "debug", "aaonly", "usevc", "primary", "igntc", "recurse", "def names", "stayopen", or "dnsrch". The string "HasWildcardMX" (without a + or -) can be specified to turn off matching against MX records when doing name canonifications. 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.

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 startup. (When running as a daemon, it changes to this user after accepting a connection but before reading any SMTP commands.)

This avoids a certain class of security problems. However, this means that all ".forward" and ":include:" files must be readable by the indicated user, and on systems that don't support the saved uid bit properly, all files to be written must be writeable by user and all programs will be executed by 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 file permissions must be loosened). However, it should be useful on firewalls and other places where users don't have accounts and the aliases file is well constrained.

RecipientFactor=fact
[y] The indicated factor is added