Appendix D
Sendmail Operation Guide

This chapter provides a detailed description of Sendmail configuration. It also provides information on the configuration file.

The information in this chapter is taken from the Sendmail Installation and Operation Guide by Eric Allman. You can find this document a www.sendmail.org.


NOTE

Refer to sendmail by Bryan Costales with Eric Allman and Neil Rickert for a comprehensive discussion of the Sendmail facility.



Introduction

Sendmail implements a general-purpose internetwork mail routing facility under the UNIX operating system. It is not tied to a particular 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 a message into a format that is appropriate for the receiving domain. All of this is done under the control of a configuration file.

Because of the requirements of flexibility for Sendmail, its configuration file can seem somewhat unapproachable. However, there are only a few basic configurations for most sites for which standard configuration files have been supplied. Most other configurations can be built by adjusting existing configuration files incrementally.

Sendmail is based on the following:

However, since Sendmail is designed to work in a wider world, in many cases it can be configured to exceed these protocols. These cases are described in this appendix.

Although you can run Sendmail without monitoring it, it has a number of features that may be used to monitor or adjust the operation under unusual circumstances. These features are described in this appendix.


Normal Operations


The System Log

The system log is supported by the syslogd(8) program. All messages from Sendmail are logged under the LOG_MAIL facility.


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. Most messages are a sequence of name=value pairs.

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

from
The envelope sender address
size
The size of the message in bytes
class
The class (that is, numeric precedence) of the message
pri
The initial message priority (used for queue sorting)
nrcpts
The number of envelope recipients for this message (after aliasing and forwarding)
msgid
The message ID of the message (from the header)
proto
The protocol used to receive this message (for example, ESMTP or UUCP)
relay
The machine from which it was received

There is also one line logged for each delivery attempt. Therefore, there can be several for each message if delivery is deferred or if there are multiple recipients. The fields are described as follows:

to
A comma-separated list of the recipients to this mailer
ctladdr
The controlling user (that is, the name of the user whose credentials Sendmail uses for delivery)
delay
The total delay between the time that this message was received and the time it was delivered
xdelay
The amount of time needed in this delivery attempt (normally indicating the speed of the connection)
mailer
The name of the mailer that is used to deliver to this recipient
relay
The name of the host that actually accepted (or rejected) this recipient
stat
The delivery status

Note that not all fields are present in all messages (for example, the relay is not listed for local delieveries).


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 useful; log levels above 64 are usually 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 called "Log Levels."


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.


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.

The mail queue should be processed transparently. However, you may have to manually intervene at times. 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.


Printing the Queue

The contents of the queue can be printed using the mailq command (or by specifying the -bp flag to Sendmail). This command 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.


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 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). The locking algorithm makes it impossible for one job to freeze the queue. However, an uncooperative recipient host or a program recipient that never returns can accumulate many processes in your system. Unfortunately, there is no way to resolve this without violating the protocol.

In some cases, a major host's going down for a couple of days may create a prohibitively large queue. This will cause Sendmail to spend an inordinate amount of time sorting the queue. This situation can be fixed 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 /usr/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/lib/sendmail -oQ/usr/spool/omqueue -q

The -oQ flag specifies an alternate queue directory and the -q flag runs every job in the queue. If you want to observe, you can use the -v flag to watch what is going on.

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

rmdir /usr/spool/omqueue


The Service Switch

The service switch controls the implementation of certain system services such as host and user name lookup. However, service switches are not completely integrated. For example, despite the fact that the host entry may look in NIS, on DYNIX/ptx systems, this will not happen because the system implementation of gethostbyname(3) does not understand this request.


The Alias Database

The alias database exists in two forms. One is a text form, maintained in the file /usr/lib/aliases. The aliases are of the following form:

name: name1, name2, ...

Only local names may be aliased; for example:

eric@prep.ai.MIT.EDU: eric@CS.Berkeley.EDU

will not have the desired effect. Aliases may be continued by starting any continuation line with a space or a tab. Blank lines and lines beginning with a pound, or sharp, sign (#) are comments.

The second form is processed by the dbm(3) (or db(3)) library. This form is in the files /usr/lib/aliases.dir and /usr/lib/aliases.pag. This is the form that Sendmail actually uses to resolve aliases. This technique is used to improve performance.


NOTE

dbm restricts a single alias to about 1000 bytes of information. You can get longer aliases by ``chaining''; that is, by making the last name in the alias a dummy name that is a continuation alias. This problem has been noted in the aliases(4) man page.


The control of the search order is 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 (for example, 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/etc/aliases

and the service switch contains

aliases nis files nisplus

then aliases will be searched in the NIS database, next in /etc/aliases, and finally in the NIS+ database.

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

OA/etc/aliases

OAnis:mail.aliases@my.nis.domain

will first search the /etc/aliases file and then the map named mail.aliases in my.nis.domain.


CAUTION

If you build your own NIS-based alias files, be sure to provide the -l flag to makedbm(8) to map uppercase letters in the keys to lowercase. Otherwise, aliases with uppercase letters in their names will not match incoming addresses.


Additional flags can be added after the colon exactly like a K line, for example:

OAnis:-N mail.aliases@my.nis.domain

will search the appropriate NIS map and always include null bytes in the key.


Rebuilding the Alias Database

The DB or DBM version of the database may be rebuilt explicitly by executing the command newaliases. This is equivalent to giving Sendmail the -bi flag:

/usr/lib/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 takes more than the rebuild timeout (option AliasWait, old a, which is normally five minutes) to rebuild the database, several processes may start the rebuild process simultaneously.

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


Potential Problems

A number of problems 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 (through being killed or a system crash) before completing the rebuild.

Sendmail has two techniques to try to relieve these problems. First, it ignores interrupts while rebuilding the database; this prevents someone from aborting the process and leaving a partially rebuilt database. Second, 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 exists.


List Owners

If an error occurs on sending to a certain address, for example 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: eric@ucbarpa
unix-wizards-request: eric@ucbarpa

would cause eric@ucbarpa to get the error that will occur when someone sends to unix-wizards. This error occurs because nosuchuser is included in 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 convention causes messages to go out with the typical Internet convention of using list-request as the return address.


User Information Database

If you have a version of Sendmail with the user information database compiled in, and you have specified 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 specified address.


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 it can be defined to be more general by using the J option. If you change this, you will have to inform your user base of the change.


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.


Errors-To:

If errors occur anywhere during processing, this header will cause error messages to go to the listed addresses rather than to the sender. This is intended for mailing lists.

The Errors-To: header was created when UUCP did not 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 has been officially deprecated and will cease to exist in a future release.


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, Sendmail will adjust the header based on the NoRecipientAction option. Therefore, Sendmail may add an Apparently-To: header line for any recipient it is aware of. This header is not used as a standard recipient line to warn any recipient that the list is not complete.

The Apparently-To: header is non-standard and has been deprecated.


Precedence

The Precedence: header can be used as a crude control of message priority. It adjusts the sort order in the queue and can be configured to change the message timeout values.


IDENT Protocol Support

Sendmail supports the IDENT protocol as defined in RFC 1413. Although this enhances identification of the author of an E-mail 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 false information.

The use of the information returned by this protocol for 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 weakening of normal host security.

An Identification server may reveal information about users, entities, objects or processes which might normally be considered private. An Identification 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 Identification. If you would not run a finger server because of privacy considerations, you may not want to run this protocol.

In some cases our system may not work properly with IDENT support because of a problem in the TCP/IP implementation. You may see symptoms in which the SMTP connection for some hosts immediately closes. If this is true or if you do not want to use IDENT, you should set the IDENT timeout to zero. This action will disable the IDENT protocol.


Arguments

The complete list of arguments to Sendmail is described in detail in the section called "Command Line Flags." Some important arguments are described here.


Queue Interval

The amount of time between forking a process to run through the queue is defined by the -q flag. If you run in delivery mode 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.

RFC 1123 section 5.3.1.1 says that this value should be at least 30 minutes (although that might not make sense if you use "queue-only" mode).


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

/usr/lib/sendmail -bd -q30m

As an alternative approach, you can invoke Sendmail from inetd(8) (use the -bsflag to ask Sendmail to speak SMTP on its standard input and output). This alternative allows you to wrap Sendmail in a TCP wrapper program, but it may be a bit slower since the configuration file has to be reread on every message that comes in. If you do this, you will still need to have Sendmail running to flush the queue:

/usr/lib/sendmail -q30m


Forcing the Queue / -q flag

In some cases you may find that the queue has gotten clogged. 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/lib/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 identifiers.


Debugging

Many debug flags have been built into Sendmail. Each debug flag has a number and a level, where a higher level means, "print out more information". The convention is that levels greater than nine are "absurd"; that is, they print out so much information that you would not normally want to see them except for debugging that particular piece of code.

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:

-d12
Set flag 12 to level 1
-d12.3
Set flag 12 to level 3
-d3-17
Set flags 3 through 17 to level 1
-d3-17.4
Set flags 3 through 17 to level 4

For a complete list of the available debug flags you will have to look at the code (they are too dynamic to keep this documentation up to date).


Changing the Values of Options

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

/usr/lib/sendmail -oT2m

sets the T (timeout) option to two minutes for this run only. The equivalent line using the long option name is

/usr/lib/sendmail -OQueueTimeout=2m

Some options have security implications. Sendmail allows you to set these but relinquishes its setuid root permissions thereafter.


Trying a Different Configuration File

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

/usr/lib/sendmail -Ctest.cf -oQ/tmp/mqueue

uses the configuration file test.cf instead of the default /usr/lib/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. Therefore, it is common to use a publicly writable directory (such as /tmp) as the spool directory (QueueDirectory or Q option) while you are testing.


Logging Traffic

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 traffic logging by using the -X flag, as shown in the following example:

/usr/lib/sendmail -X/tmp/traffic -bd

This logs 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.


Testing Configuration Files

When you build a configuration table, you can do some testing by using the test mode of Sendmail. For example, you can invoke Sendmail as

sendmail -bt -Ctest.cf

which will read the configuration file test.cf and enter test mode. In this mode, you enter lines in the form:

rwset address

where rwset is the rewriting set that 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 that 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 rule set 3 to the input monet:bollard. Rule set 1 is then applied to the output of rule set 3, followed similarly by rule sets 21 and 4.

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.

Be warned that internally, Sendmail applies rule set 3 to all of the addresses. In test mode you will have to do that manually. For example, older versions allowd you to use

0 bruce@broadcast.sony.com

This version of Sendmail requires that you use

3,0 bruce@broadcast.song.com

As of version 8.7, some other syntaxes are available in the test mode:


Tuning

Several configuration parameters can be changed, 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 default appropriately for most sites. However, sites having very high mail loads may find 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 find that they need to adjust the parameters dealing with queue priorities.

All versions of Sendmail before 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 that you most likely will want to adjust. Read the section entitle "The Configuration File" for more information.


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 following list describes the full scale syntax:

s
seconds
m
minutes
h
hours
d
days
w
weeks

Queue Interval

The argument to the -q flag specifies how often a subdaemon runs 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.


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 as follows:

connect
The time to wait for an SMTP connection to open (the connect(2) system call) [0, unspecified]. If zero, it uses the kernel default. In no case can this option extend the timeout longer than the kernel provides, but it can shorten it. This behavior allows it to get around kernels that provide an absurdly long connection timeout (90 minutes in one case).
initial
The wait for the initial 220 greeting message (5m, 5m).
helo
The wait for a reply from a HELO or EHLO command (5m, unspecified). This may require a hostname lookup, so five minutes is probably a reasonable minimum.
mail*
The wait for a reply from a MAIL command (10m, 5m).
rcpt*
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.
datainit*
The wait for a reply from a DATA command (5m, 2m).
datablock*
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 that have no guarantee of promptness.
datafinal*
The wait for a reply from the dot that terminates a message (1h, 10m). If this is shorter than the time actually need for the receiver to deliver the message, duplicates will be generated. This is discussed in RFC1047.
rset
The wait for a reply from a RSET command (5m, unspecified).
quit
The wait for a reply from a QUIT command (2m, unspecified).
misc
The wait for a reply from miscellaneous (but short) commands, such as NOOP (no-operation) and VERB (go into verbose mode) (2m, unspecified).
command*
In server SMTP, the time to wait for another command (1h, 5m)
ident
The timeout waiting for a reply to an IDENT query (30s, unspecified).

For compatibility with old configuration files, if no suboption is specified, all of the timeouts marked with * are set to the indicated value.

Many of the RFC 1123 minimum values may be too short. Sendmail was designed to the RFC 822 protocols, which did not specify read timeouts. Hence, Sendmail does not guarantee to reply to messages promptly. In particular, an RCPT command specifying a mailing list will expand and verify the entire list; a large list on a slow system may take more than five minutes. A one-hour timeout is best; since this failure is rare, a long timeout is not onerous and may ultimately help to reduce the network load and duplicated messages. For example, the line

O Timeout.command=25m
0 Timeout.datablock=3h

sets the server SMTP command timeout to 25 minutes and the input data block timeout to three hours.


Message Timeouts

After sitting in the queue for a few days, a message times out. This insures that at least the sender is aware of the inability to send a message. The timeout is typically set to five days. Sometimes it is convenient to also send a warning message if the message is in the queue longer than a few hours (assuming that you normally have good connectivity; if your messages normally took several hours to send you would not want to do this because it would not be an unusual event). These timeouts are set by using the Timeout.queuereturn and Timeout.queuewarn options in the configuration file (previously both were by using the T option.

Since this option is global, and since you cannot know how long another host outside your domain will be down, a five-day timeout 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 to 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 value

OT5d/4h

causes E-mail 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.


Forking During Queue Runs

By setting the ForkEachJob (Y) option, Sendmail forks before each individual message while running the queue. This prevents 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 keeps track of hosts that are down during a queue run. This can improve performance dramatically.

If the ForkEachJob option is set, Sendmail cannot use connection caching.


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 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 factor is also included in 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 3000 (for the recipient factor) and 1800 (for the class factor). The initial priority is:

pri = msgsize - (class x ClassFactor) + (nrcpt x RecipientFactor)

(Remember that 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 Z option defaults to 90000.


Load Limiting

Sendmail can be asked to queue (but not deliver) mail if the system load average gets too high with 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.


Delivery Mode

Sendmail can operate in a number of delivery modes. These modes specify how quickly mail will be delivered. The DeliveryMode (d) configuration option specifies the delivery modes. Legal modes are as follows:

i
Deliver interactively (synchronously)
b
Deliver in background (asynchronously)
q
Queue only (do not deliver)
d
Defer delivery attempts (do not deliver)

There are tradeoffs. Mode i gives the sender the quickest feedback, but it may slow down some mailers and is hardly ever necessary. Mode q puts the minimum load on your machine, but delivery may be delayed. Mode b is probably a good compromise. However, this mode can cause a large number of processes if you have a mailer that takes a long time to deliver a message. Mode d is identical to mode q except that it also prevents all of the early map lookups from working. It is intended for dial on demand sites in which DNS lookups might be monetarily expensive. Some simple error messages (for example, host unknown during the SMTP protocol) will be delayed by 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.


Log Levels

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

0
No logging.
1
Serious system failures and potential security problems.
2
Lost communications (network problems) and protocol failures.
3
Other serious failures.
4
Minor failures.
5
Message collection statistics.
6
Creation of error messages, VRFY and EXPN commands.
7
Delivery failures (such as host or user unknown).
8
Successful deliveries and alias database rebuilds.
9
Messages being deferred (for example, because of a host being down).
10
Database expansion (alias, forward, and user database lookups).
20
Logs attempts to run locked queue files. These are not errors but can be useful to note if your queue appears to be clogged.
30
Lost locks (only if using lockf instead of flock).

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


File Modes

Many files can have a number of modes. The modes depend on what functionality you want and the level of security you require.


To Set the User ID or Not to Set the User ID

Sendmail can safely be made to set the user ID (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 user ID and group ID to a default (set by the u and g options). (This reset can be overridden by setting the S flag to the mailer for mailers that are trusted and must be called as root. However, doing so will cause mail processing to be accounted (using sa) to root rather than to the user sending the mail.)

If you do not make Sendmail set the user ID (setuid) to root, it will still run, but you will lose a lot of functionality and privacy, since you will have to make the queue directory word readable. You can also make Sendmail set the user ID (setuid) to some pseudo-user (for example, create a user called sendmail and make Sendmail set the user ID (setuid) to that), which will fix the privacy problems but not the functionality issues. Also, this is not a guarantee of security. For example, root occasionally sends mail, and the daemon often runs as root.


Should My Alias Database Be Writable?

Berkeley has the alias database (usr/lib/aliases*) mode 644. While this is not as flexible as if the database were mode 666, it avoids potential security problems with a globally writable database.

The database that Sendmail actually used is represented by the two files aliases.dir and aliases.pag (both in /usr/lib) (or aliases.db if you are running with the new Berkeley database primitives). The mode on these files should match the mode on /usr/lib/aliases. If aliases is writable 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 writable, a slightly sophisticated user can arrange to steal mail anyway.

If your DBM files are not writable 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 with the newaliases utility. If this step is ignored or forgotten, any intended changes will also be ignored or forgotten.


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 a NOOP command. It is not an error if this fails. Instead, the connection is closed and reopened.

Two parameters, ConnectionCacheSize (k) and ConnectionCacheTimeout (K), 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 ConnectionCacheSize (K) option specifies 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 five minutes.


Name Server Access

The hosts service entry in your service switch file controls the host address lookups. Sendmail will consult the /etc/service.switch file. Sendmail only uses two entries: hosts and aliases.

However, some systems will do DNS lookups regardless of the setting of the service switch entry. In particular, the gethostbyname(3) system routine is used to look up host names, and many vendor versions try some combination of DNS, NIS, and file 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 name server configured at all, 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 indicate a temporary failure and will queue the mail for later processing. Otherwise, it ignores the name server data.

The same techniques can be 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 also allows you to tweak name-server options. The command line takes a series of flags as documented in resolver(3). 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 by default turn DNSRCH, DEFNAMES, and RECURSE flags on and all others off. Note the use of the initial "True" - this is for compatibility with previous versions of Sendmail, but is not otherwise necessary.

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 do not want to do automatic name extensions, do not call $[ ... $].

The search rules for $[ ... $] are somewhat unusual. If the name (that is, the " ... ") has at least one dot, it always tries the unmodified name first. If that fails, it tries the reduced search path, and last 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 "uts.CS" to match the site 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.

To completely turn off all name-server access on systems without service switch support, you will have to recompile with -DNAMED_BIND=0 and remove -lresolv from the list of libraries to be searched when linking.


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 configuration 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 in the user's home directory is searched. A site could also search by sender, 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.


Free Space

On systems that have the statfs(2) system call, you can specify a minimum number of free blocks on the queue filesystem, using the MinFreeBlocks (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 E-mail when that mail would be processed without difficulty.


Maximum message Size

To avoid overflowing your system with a large message, the MaxMessageSize option can be set to indicate an absolute limit on the size of any one message. This will be advertised in the ESMTP dialogue and checked while messages are collected.


Privacy Flags

The PrivacyOptions (p) option allows you to set certain "privacy" flags. Actually, many of them do not give you any extra privacy; rather, they just insist 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.


Send to Me Too

Normally, Sendmail deletes the (envelope) sender from any list expansions. For example, if matt sends a list that contains matt as one of the members, he will not get a copy of the message. If the -m (me too) command line flag is set, 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.


The Configuration File

This section describes the configuration file in detail.

One point that should be made clear immediately: the syntax of the configuration file is designed to be reasonably easy to parse, since this is done every time Sendmail starts up, rather than easy for a human being to read or write. 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.


R and S Rewriting Rules

Rewriting tools form the core of address parsing. 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 S command has the following form:

Sn

This command sets the current rule set being collected to n. If you begin a rule set more than once, it deletes the old definition.

The R command has the following form:

Rlhs rhs comments

The fields must be separated by at least one tab character, and there may be embedded spaces in the fields. The lhs field is a pattern that is applied to the input. If it matches, the input is rewritten to the rhs field. 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 runtime by using a somewhat less general algorithm. This form is only for referencing internally defined macros, such as $h, which are changed at runtime.


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 as follows:

$*
Match zero or more tokens.
$+
Match one or more tokens.
$-
Match exactly one token.
$= x
Match any phrase in class x.
$~ 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      UCBARPA
$2      eric

Additionally, the LHS can include $@ to match zero tokens. This not bound to a $N on the RHS, and is normally only used when it stands alone in order to match the null input.


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 as follows:

$ n
Substitute indefinite token n from LHS.
$[name$]
Canonize name.
$(map key $@arguments $:default $)
Generalized keyed mapping function.
$>n
"Call" rule set 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 hostname enclosed between $[ and $] is looked up using the gethostent(3) routines and replaced by the canonical name. For example, $[csam$] might become lblcsam.arpa and $[[128.32.130.2]$] would become vangogh.CSBerkeley.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 $>n syntax causes the remainder of the line to be substituted as usual and then passed as the argument to rule set n. The final value of rule set n then becomes the substitution for this rule.

The $# syntax should only be used in rule set zero or a subroutine of rule set zero. It causes evaluation of the rule set to terminate immediately and signals to Sendmail that the address has completely resolved. The complete syntax is as follows:

$#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. 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 value to $# is "local" and the first character of the $: value is @, the @ is stripped off and a flag is set in the address descriptor that causes Sendmail not to do rule set 5 processing.

Normally, a rule that matches is retried. That is, the rule loops until it fails. A RHS may also be preceded by a $2 or a $: to change this behavior. A $@ prefix causes the rule set to return with the remainder of the RHS as the value. A $: prefix causes the rule to terminate immediately, but the rule set 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, as in the following example:

R$+     $: $>7 $1

matches anything, passes that to rule set 7, and continues; the $: is necessary to avoid an infinite loop.

Substitution occurs in the order described. That is, parameters from the LHS are substituted, hostnames are made canonical, subroutines are called, and finally $#, $@, and $: are processed.


Semantics of Rewriting Rule Sets

There are five rewriting sets that have specific semantics. Four of these are related as depicted by Figure D-1.

Rule set 3 should turn the address into canonical form. This form should have the basic syntax:

local-part@host-domain-spec

Rule set 3 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 D-1) from the sender address (if the C flag is set in the mailer definition corresponding to the sending mailer).



Figure D-1. Rewriting set semantics.


The following information applies to Figure D-1 .

D
Sender domain addition
S
Mailer-specific sender rewriting
R
Mailer-specific recipient rewriting

Rule set 0 is applied after rule set 3 to addresses that are actually going to actually specify recipients. It must resolve to a (mailer, host, user) tuple. 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.

Rule sets 1 and 2 are applied to all sender and recipient address respectively. They are applied before any specification in the mailer definition. They must never resolve.

Rule set 4 is applied to all addresses in the message. It is typically used to translate internal to external form.


IPC Mailers

Some special processing occurs if the rule set 0 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 up the name in DNS to find alternate delivery sites.

The host name can also be provided as a dotted quad in square brackets, for example, [123.32.148.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, for example, [ucbvax.berkeley.edu]. This form avoids the MX mapping.


NOTE

This is intended only for situations where you have a network firewall - 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.



D - Define Macro

Macros are named with a single character. These 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.

Macro definitions have the following syntax:

Dx val

x is the name of the macro, and val is the value it should have. Macros can be interpolated in most places using the escape sequence $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 following syntax:

$?x test1 $| test2 $

This interpolates test1 if the macro $x is set, and test2 otherwise. The else ($|) clause may be omitted.

Lowercase macro names are reserved to have special semantics that are used to pass information in or out of Sendmail, and special characters are reserved to provide conditionals. Uppercase names (that is, $A through $Z) are specifically reserved for configuration file authors.

The following macros are defined and/or used internally by Sendmail for interpolation into argvs for mailers or for other contexts. The ones marked * are information passed into Sendmail. 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 the following:

$a
The origination date in RFC 822 format. This is extracted from the Date: line.
$b
The current date in RFC 822 format.
$c
The hop count.
$d
The current date in UNIX (ctime) format.
$e*
(Obsolete; use SmtpGreetingMessage option instead.) The SMTP entry message. This is printed out when SMTP starts up. The first word must be the $j macro as specified by RFC821. Defaults to Fj Sendmail $v ready at $b . Commonly redefined to include the configuration version number, for example, $j Sendmail $v/$Z ready at $b.
$f
The envelope sender (from) address.
$g
The sender address relative to the recipient. For example, if $f is foo, $g will be host!foo, foo@host.domain, or whatever is appropriate for the receiving mailer.
$h
The recipient host. This is set in rule set 0 from the $# field of a parsed address.
$i
The queue ID (for example, HAA12345).
$j**
The "official" domain name for this site. This is fully qualified if the full qualification can be found. It must be redefined to be the fully qualified domain name if your system is not configured so that information can find it automatically.
$k
The UUCP node name (from the uname system call).
$1
(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.
$m
The domain part of the gethostname return value. Under normal circumstances, $j is equivalent to $w.$m.
$n*
The name of the daemon (for error messages). Defaults to MAILER-DAEMON.
$o*
(Obsolete: use OperatorChars option instead.) The set of operators in addresses. A list of characters that 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.
$p
Sendmail's process ID.
$q*
Default format of sender address. The $q macro specifies how an address should appear in a message when it is defaulted. Defaults to <$g>. It is commonly redefined to be $?x$x<$g>$|$g$. or $g$?x ($x)$., corresponding to the following two formats:

Eric Allman <eric@CS.Berkeley.EDU>
eric@CS.Berkeley.EDU (Eric Allman)

Sendmail properly quotes names that have special characters if the first form is used.

$r
Protocol used to receive the message. Set from the -p command line flag or by the SMTP server code.
$s
Sender's host name. Set from the -p command line flag or by the SMTP server code.
$t
A numeric representation of the current time.
$u
The recipient user.
$v
The version number of the Sendmail binary.
$w**
The host name of this site. The is the root name of this host (but see below for caveats).
$x
The full name of the sender.
$z
The home directory of the recipient.
$_
The validated sender address.

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 find the fully qualified name of the host if at all possible. It does this by calling gethostname(2) to get the current host name and then passing that to gethostbyanme(3), which is supposed to return the canonical version of the host name. If this operation 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 configuration file set $j to the fully qualified domain name.

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 (using "eric" above) eric sends 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.Berekely.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 a flag to Sendmail. The second choice is the value of the Full-name: line in the header if it exists, and the third 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 are set to the host, user, and home directory (if local) of the recipient. The first two are set from the $@ and $: part of the rewriting rules, respectively.

The $p and $t macros are used to create unique strings (for example, 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 normally put in timestamps and has proved extremely useful for debugging.

The $c field is set to the hop count; that is, 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 host name.

The $_ is set to a validated sender's host name. If the sender is running an RFC 1413-compliant IDENT server, it will include the user name on that host.


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 a site might be created so that attempts to send to oneself can be eliminated. These local names can either be defined directly in the configuration file or read in from another file. Classes may be given names from the set of uppercase letters. Lowercase letters and special characters are reserved for system use.

The C and F classes have the following syntax:

Cc phrase1 phrase2

Fc file

The C form defines the class c to match any of the named phrases. You can split the named phrases among multiple lines. For example, the C form:

CHmonet ucbmonet

is equivalent to

CHmonet
CHucbmonet

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. Multiword entries in the class are ignored in this context.

The class $=w is set to be the set of all names by which this host is known. This can be used to match local host names.

The class $=k is set to be the same as $k, that is, the UUCP node name.

The class $=m is set to the set of domains by which this host is known, initially by just $m.

The class $=t is set to the set of trusted users by the T configuration line. To read trusted users from a file, use Ft/file/user.

The class $=n can be set to the set of MIME body types that can never be 8 to 7-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. The class $=e contains the Content-Transfer-Encodings that can be 8 to 7-bit encoded. it is predefined to contain 7bit, 8bit, and binary. The class $=s contains the set of subtypes of messages that can be treated recursively. By default it contains only rfc822. Other message/* types cannot be 8 to 7-bit encoded. If a message containing 8-bit data is sent to a 7-bit host and that message cannot be encoded into 7 bits, it will be stripped to 7 bits.

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

FL/etc/passwd %[^:]

which reads every line up to the first colon.


M - Define Mailer

The M line defines programs and interfaces to mailers and has the following format:

Mname, {field=value}*

name is the name of the mailer (used internally only). The field=name pairs define attributes of the mailer. The following list defines the fields:

Path
The pathname of the mailer
Flags
Special flags for the mailer
Sender
A rewriting set for sender addresses
Recipient
A rewriting set for recipient addresses
Argv
An argument vector to pass to the mailer
Eol
The end-of-line string for the mailer
Maxsize
The maximum message length to the mailer
Linelimit
The maximum line length in the message body
Directory
The working directory for the mailer
Userid
The default user and group ID to run as
Nice
The nice(2) increment for the mailer
Charset
The default character set for 8-bit characters
Type
The MTS type information (used for error messages)

Only the first character of the field name is checked.

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 used to correlate the flags portion of the H line. Flags marked with ** apply to the mailers for the sender address rather than the usual recipient mailers.

a
Run Extended SMTP (ESMTP) protocol (defined in RFCs 1651, 1652, and 1653). This flag defaults to on if the SMTP greeting message includes the word ESMTP.
A
Look up the user part of the address in the alias database. Normally this is only set for local mailers.
b
Force a blank line on the end of a message. This works around some poorly-written versions of /bin/mail that require a blank line but do not provide it themselves. It would not normally be used on network mail.
c
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 flag set, any addresses in the header that do not have an "at" sign (@) after being rewritten by rule set 3 will have the "@domain" clause from the sender tacked on. This allows mail with headers of the following form:
From: usera@hosta
To: userb@hostb, userc

to be automatically rewritten as:

From: usera@hosta
To: userb@hostb, userc@hosta

However, it does not work reliably.

D*
This mailer wants a Date: header line.
e
This mailer is expensive to connect to. So try to avoid connecting normally; any necessary connection will occur during a queue run.
E
Escape lines beginning with From in the message with a > sign.
f
The mailer wants a -ffrom flag but only if this is a network forward operation (that is, the mailer will give an error if the executing user does not have special permissions).
F*
This mailer wants a From: header line.
g
Normally, Sendmail sends internally generated E-mail (for example, error messages) using the null return address as required by RFC 1123. However, some mailers do not accept a null return address. If necessary, you can set the g flag to prevent Sendmail from obeying the standards. Error messages will be sent as from the MAILER-DAEMON (actually, the value of the $n macro).
h
Uppercase should be preserved in host names for this mailer.
I
This mailer will be speaking SMTP to another Sendmail. As such, it can use special protocol features. This options is not required (that is, if this option is omitted, the transmission will still operate successfully, although perhaps not as efficiently as possible).
k
Normally when Sendmail connects to a host via SMTP, it checks to make sure that this is not accidently the same host name as might happen if Sendmail is misconfigured or if a long-haul network interface is set in loopback mode. This flag disables the loopback check. It should only be used under very unusually circumstances.
K
Currently unimplemented. Reserved for use later.
l
This mailer is local (That is, final delivery will be performed).
L
Limit the line lengths as specified in RFC821. This deprecated option should be replaced by the L= mail declaration. For historic reasons, the L flag also sets the 7 flag.
m
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 definition, that field will be repeated as necessary for all qualifying users.
M*
This mailer wants a Message-Id: header line.
n
Do not insert a UNIX-style From line on the front of the message.
o
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 specified 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 flag is ignored if the S flag is set.
p
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 officially discouraged by RFC 1123.
P*
This mailer wants a Return-Path: line.
r
Same as f but sends a -r flag.
s
Strip quote characters off of the address before calling the mailer.
S
Do not reset the userid before calling the mailer. This could be used in a secure environment where Sendmail ran as root. This could be used to avoid forged addresses. If the U= field is also specified,this flag causes the user ID to always be set to that user and group (instead of leaving it as root).
u
Uppercase should be preserved in user names for this mailer.
U
This mailer wants UNIX-style From lines with the ugly UUCP-style remote from <host> on the end.
w
The user most have a valid account on this machine (that is getpwnam must succeed). If not, the mail is bounced. This is required to get ".forward" capability.
x*
This mailer wants a Full-Name: header line.
X
This mailer wants to use the hidden-dot algorithm as specified in RFC821. Basically, any line beginning with a dot will have an extra dot prefixed (to be stripped at the other end). This insures that lines in the message containing a dot will not terminate the message prematurely.
5
If no aliases are found for this address, pass the address through rule set 5 for an alternate resolution. This option forwards the mail to an alternate delivery spot.
7
Strip all output to seven bits. This is the default if the L flag is set. Note that clearing this options is not sufficient to get full 8-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 only impacts messages that do not perform 8 to 7-bit MIME conversions.
8
If set, you can sent 8-bit data to this mailer. The usual attempt at 8 to 7-bit MIME conversions will be bypassed.
:
Check addresses to see if they begin with an :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 *file* mailer.
@
Look up addresses in the user database.

Configuration files before level 7 assume the A, w, 5, :, |, /, and @ options on the mailer named local.

This 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. 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 rule set 0 or 5.

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, file, 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 be either a simple rule set ID or 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 should 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 normal users, csh scripts as recipients can fail.

The Userid specifies the default user and group ID, overriding the DefaultUser option. If the S mailer flag is also specified, this is the user and group to run as in all circumstances. The Userid 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.


NOTE

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. It is 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.


H- Define Header

The H line defines the format of the header lines that Sendmail inserts into the message and has the following syntax:

H[?mflags?]hname: htemplate

Continuation lines in this appendix 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 the header to be automatically output. An input header is reflected to the output regardless of these flags.

Some headers have special semantics that are described below.


O - Set Option

A number of global options can be set from a configuration file. These options are represented by full words, although some are also represented as single characters for back compatibility. The syntax of this line is as follows:

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

Here, 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 with TRUE as the default), or a time interval.

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

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), hash (if NEWDB is specified, 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 timeout interval, rebuild the database (if the AutoRebuildaliases option is also set) or issue a warning.
AutoRebuildAliases
[D] If set, rebuild the alias database if necessary and possible. If this optionis no 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 (that is, no change is made).
CheckAlias
[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 high Priority: will be favored. Defaults to 1800.
ColonOkInAddr
[no short name] if set, colons are acceptable in e-mail addresses (for example, host:user). If not set, colons indicate the beginning of a RFC 822 group construct (groupname: member1, member2, ... memeberN;). Doubled colons are always acceptable (nodename::user) and proper route-address nesting is understood (<@relay:user@host>). Furthermore, this option defaults on if the configuration version level is less than 6 (for backwards 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 option consumes file descriptors, the connection cache should be kept small: 4 is a practical maximum.
ConnectionCacheTime out=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 to ten minutes). Before Sendmail uses a cached connection, it always sends a NOOP (no operation) command to check the connection. If this fails, it reopends 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.
DaemonPortOptions =options
[O] Set server SMTP options. The options are key=value pairs. Known keys are described as follows:

Port - Name/number of listening port (defaults toSMPT)

Addr - Address mask (defaults to INADDR_ANY)

Family - Address family (defaults to INET)

Listen - Size of listen queue (defaults to 10)

SndBufSize - Size of TCP send buffer

RcvBufSize - Size 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 user ID 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. The value can also be given as a symbolic user name.
DeliveryMode=x
[d] Deliver in mode x. Legal modes are as follows:

i - Deliver interactively (synchronously)

b - Deliver in background (asynchronously)

q - Just queue the message (deliver during queue run)

Defaults to b if no option is specified, i if it is specified but given no argument (that is, Od is equivalent to Odi). The -v command line flag sets this to i.

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 first 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; therefore, DialDelay=5 uses a five second delay. Defaults to zero (no retry).
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 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(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 file), which will make file access permissions somewhat more restrictive. Has no effect on systems that do not have group lists.
DontPruneRoutes
[R] Normally, Sendmail tries to eliminate any unnecessary explicit routes when sending an error message (as discussed in RFC 1123 section 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.

EightBitMode=action
[8] Set handling of 8-bit data. There are two kinds of 8-bit data: 1) that which is declared as such by using the BODY=8BITMIME ESMTP declaration or the -B8BITMIME command line flag, and 2) undeclared 8-bit data (that is, input that happens to be eight bits. Three basic operations 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-bit 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.

ErrorHeader=file-or-messagefile/message
[E] Prefix 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, E-mail address, and/or phone number of a local postmaster who could provide assistance in to end users. If the option is missing or null, or if it names a file that does not exist or which is not readable, no message is printed.
ErrorMode=x
[e] Dispose of errors using mode x. The values are as follows:

p - Print error messages (default)

q - No messages, just give exit status

m - Mail back errors

w - Write back errors (mail if user not logged in)

e - Mail back errors and give zero exit status always

FallbackMXhost= fallbackhost
[V] If specified, the fallbackhost acts like a very low-priority MX on every host. This should be used by sites with poor network connectivity.
ForkEachJob
[Y] If set, delivers 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/.forward. 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/forward/$u:$z/.forward will search first in /var/forward/username and then in ~username/.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, do not connect immediately. This requires that queuing be compiled in, since it will depend on a queue run process to actually send the mail.
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 the 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.
MaxHopCount=N
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, connections to that host will not be retried for this internal. The units default to minutes.
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 the 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.
MeToo
[m] Send to me too, even if I am in an alias expansion.
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.
MinFreeBlocks=N
[b] Insist on at least N blocks free on the filesystem that holds the queue files before accepting E-mail 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] Do not process any queued jobs that have been in the queue less than the indicated time interval. This will 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.
NoRecipientAction
[no short name] The action to take when you receive a message that has no valid recipient headers (To:, Cc:, Bcc:). 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 backwards compatibility and is officially deprecated), 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; that is, 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.
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 selection from the following:

public - Allows open access.

needmailhelo - Insists on HELO or EHLO command before MAIL.

needexpnhelo - Insists on HELO or EHLO command before EXPN.

noexpn - Disallows EXPN entirely.

needvrfyhelo - Insists on HELO or EHLO command before VRFY.

novrfy - Disallows VRFY entirely.

restrictmailq - Restricts mailq command.

restrictqrun - Restricts -q command line flag.

noreceipts - Ignores Return-Receipt-To: header.

goaway - Disallows all SMTP status queries.

authwarnings - Puts 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 E-mail system, such as using a non-standard queue directory.

QueueFactor=dir
[Q] Use the named directory 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 (that is, do not try to send them). Defaults to 9.
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) and "priority" (to order strictly 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 should not be used on slow network links.
ResolverOptions= options
[I] Set resolver options. Values can be set by using the +flag and cleared by using the -flag. The flags can be debug, aaonly, usevc, primary, igntc, recurse, defnames, stayopen, or dnsrch. The string HasWildcardMX (without a + or -) can be specified to turn off matching against MX records when doing name canonifications.

Note that before Version 8.7, this option indicated that the name server be responding in order to accept addresses. This has been replaced by checking to responding in order to accept addresses. This has been replaced by checkin to see if the "dns" method is listed in the service switch entry for the "hosts"service.

SmtpGreetingMessage= message
[$e macro] The message printed when the SMTP server starts up. Defaults to $j sendmail $v ready at $b.
Timeout.type=timeout
[r; subsumes old T option as well] The recognized timeouts, their default values, and their minimum values specified in RFC 1123 section 5.3.2 are as follows:

inital
Wait for initial greeting message (5m, 5m).
helo
Reply to HELO or EHLO command (5m, none)
mail
Reply to MAIL command (10m, 5m)
rcpt
Reply to RCPT command (1h, 5m)
datainit
Reply to DATA command (5m, 2m)
datablock
data block read (1h, 3m)
datafinal
Reply to final dot (.) in data (1h, 10m)
rset
Reply to RSET command (5m, none)
quit
Reply to QUIT command (2m, none)
misc
Reply to NOOP and VERB commands (2m, none)
ident
IDENT protocol timeout (30s, none)

All but command apply to client SMTP. For back compatibility, a timeout with no keywords= part will set all of the longer values.

command*
Command read (1h, 5m)
fileopen*
Timeout on opening .forward and :include: files (60s, none)
queuereturn*
How long until a message is returned (5d, 5d)
queuewarn*
How long until a warning is sent (none, none)

All but those that are marked with an asterisk (*) apply to client SMTP. If the message is submitted by using the NOTIFY SMTP extension, warning messages will only be sent if NOTIFY=DELAY is specified. The queuereturn and queuewarn timeouts can be further qualified with a tag based on the Precedence: field 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.

RecipientFactor=fact
[y] The indicated factor is added to the priority (thus lower the priority of the job) for each recipient. That is, 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.
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.
SaveFromLine
[f] Save UNIX-style From lines at the front of headers. Normally, they are assumed to be redundant and are discarded.
SendMIMEErrorspath
[j] If set, send error messages in MIME format (see RFC 1521 and RFC 1344 for details).
ServicesSwitchFile= filename
[no short name] if your host has a service switch abstraction that switch will be consulted and this option is ignored. Otherwise this is the name of a file that provides the list of methods used to implement particular services. The syntax is a series of lies, each of which is a sequence of words. The first 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 "files" (with the caveat that the appropriate support must be compiled in before the service can be referenced). If ServicesSwitchFile is not specified, it defaults to /etc/service.switch. If that file does not exist, the default switch is

   aliases     files
   hosts       dns nis files

The default file is /etc/service.switch.

SevenBitInput
[7] Strip input to seven bits for compatibility with old systems. This should not be necessary.
StatusFile=file
[S] Log summary statistics in the named file. If not set, no summary statistics are saved. This file does not grow in size. It can be printed by using the mailstats(8) program.
SuperSafe
[s] Be very careful (super safe) when running things. That is, always instantiate the queue file, even if you are going to attempt immediate delivery. Sendmail always instantiates the queue file before returning control to the client under any circumstances. This should always be set.
TempFileMode=mode
[F] The file mode for queue files. It is interpreted in octal by default. Defaults to 0600.
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 the local time zone is set but null, the user's TZ variable is used, and if it is set and non-null, the TZ variable is set to this value.
TryNullMXList
[x] If you are the "best" (that is, lowest preference) MX for a given host, you 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 firewalls), 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 configuration are likely to be diagnosed as host unknown or message timed out instead of something more meaningful. This option is not recommended.
UnixFromLine=fromline
[$1 macro] Defines the format used when Sendamil must add a UNIX-style From_ line (that is, a line beginning From<space>user). Defaults to From $g $d. Do not change this unless your system uses a different UNIX mailbox format (very unlikely).
UseErrorsTo
[I] 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 not recommended and has been deprecated.
UserdatabaseSpec= udbspec
[U] The user database specification.
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 single job so that you can see the entire delivery process. Option Verbose should never be set in the configuration file. It is intended for command line use only.

All options can be specified on the command line using the -O or -o flag, but most will cause Sendmail to relinquish its setuid permissions. The options that will not cause this are MinFreeBlocks [b], DeliveryMode [d], ErrorMode [e], IgnoreDots [i], LogLevel [L], MeToo [m], OldStyleHeaders [o], PrivacyOptions [p], Timeouts [r], SuperSafe [s], Verbose [v], CheckpointInterval [C], and SevenBitInput [7]. Also, M (define macro) when defining the r or s macros, is also considered "safe".


P - Precedence Definitions

Values for the Precedence: field may be defined using the P control line. This field has the following syntax:

Pname=num

When the name is found in a Precedence: field, 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 process, 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 as follows:

Pfirst-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) did not 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.


V - Configuration Version Level

To provide compatibility with old configuration files, the V line has been added to define some very basic semantics of the configuration file. These are not intended to be long-term supports. Rather, they describe compatibility features that will probably be removed in future releases.


NOTE

These version levels have noting to do with the version number on the files. For example, as of this writing version 8 configuration files (specifically 8.67) used version level 6 configurations.


Old configuration files are defined as version-level one. Version level two files make the following changes:

Version-level-three files allow # initiated comments on all lines. Exceptions are backslash-escaped # marks and the $# syntax.

Version-level-four configurations are completely equivalent to level three for historical reasons.

Version-level-five configuration files change the default definition of $w to be just the first component of the host name.

Version-level-six configuration files change many of the local processing options (such as aliasing and matching the beginning of the address for | characters) to be mailer flags. This action allows fine-grained control over the special local processing. Level-six configuration files may also use long option names. The ColonOkInAddr option (to allow colons in the local part of addresses) defaults to on for lower-numbered configuration files. The configuration file requires some additional intelligence to properly handle the RFC 822 group construct.

The V line may have an optional /vendor to indicate that this configuration file uses modifications specific to a particular vendor. You can use /Berkeley to emphasize that this configuration file used the Berkeley dialect of Sendmail.


K - Key File Declaration

Special maps can be defined using the following 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 file containing the map.

Maps are referenced by the following 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 function. If it returns a value, it replaces the input. If that does not return a value and the default is specified, the default replaces the input. Otherwise, the input is unchanged.

During the replacement of either a map value or default, the string %n (where n is a digit) is replaces by the corresponding argument. Argument zero is always the database key. For example, the rule

R$-!$+        $: $(uucp $1 $@ $2$: %1@ %0. UUCP $)

looks up the UUCP name in a (user defined) UUCP map. If not found, it turns it into .UUCP form. The database might contain records like:

decvax          %1@%0.DEC.COM
research        %1@%0.ATT.COM

The built-in map with both name and class host is the host name canonicalization lookup. Therefore, the following syntax:

$(host hostname$)

is equivalent to:

$[hostname$]

The predefined database lookup classes are defined below:

dbm
Database lookups using the ndbm(3) library. Sendmail must be compiled with NDBM defined.
btree
Database lookups using the btree interface to the Berkeley db(3) library. Sendmail must be compiled with NEWDB defined.
hash
Database lookups using the hash interface to the Berkeley db(3) library. Sendmail must be compiled with NEWDB defined.
nis
NIS lookups. Sendmail must be defined with NIS defined.
nisplus
NIS+ lookups. Sendmail must be defined with NISPLUS defined. The argument is the name of the table to use for lookups. The -k and -v flags may be used to set the key and value columns respectively.
hesiod
Hesiod lookups. Sendmail must be compiled with HESIOD defined.
netinfo
NeXT® Netinfo lookups. Sendmail must be compiled with NETINFO defined.
text
Text file lookups. The format of the textfile is defined by the -k (key field number), -v (value field number, and -z (field delimiter) flags.
stab
Internal symbol table lookups. Used internally for aliasing.
implicit
Should be called "alias"; this class is used to get the default lookups for alias files and is the default if no class is specified for alias files.
user
Looks up users using getpwnam(3). The -v flag can be used to specify the name of this field to return (although this is normally used only to check the existence of a user).
host
Provides the canonical name for the host domain names. After it is given a host name, it calls the name server to find the canonical name for that host.
sequence
The arguments on the K line are a list of maps. The resulting map searches the argument maps in order until it finds a match for the indicated key. For example, if the key definition is:
     Kmap1 ...
     Kmap2 ...      Kseqmap sequence map1 map2

then a lookup against seqmap first does a lookup in map1. If that is found, it returns immediately. Otherwise, the same key is used for map2.

switch
Similar to 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 definition:
     Kali switch aliases

together with the service switch entry:

     aliases          nis files

This causes a query against the map ali to search maps named ali.nis and ali.files in that order.

dequote
Strip double quotes ('') from a name. It does not strip blackslashes 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). This class is useful when you are trying to accept mail from systems such as DECnetTM, which routinely quote odd syntax, such as:
     ``49ers::ubell''
A typical usage is probably something like:
     Kdequote dequote

     ...

     R$-          $:$(dequote $1 $)
     R$- $+       $: $>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.

Most of these classes accept as arguments the same optional flags and a filename (or a mapname for NIS; the filename 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 flags are as follows:

-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 were empty.
-N, -O
If neither -n nor -O is specified, 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 finds any key with a null byte, it never tries again without a null byte and vice versa. If -N is specified, it never tries without a null byte, and if -O is specified, it never tries with a null byte. Setting one of these, can speed matches but is never necessary. If both -N and -O are specified, Sendmail will never try any matches at all. That is, everything will appear to fail.
-ax
Append the string x on successful matches. For example, the default host map appends a dot on successful matches.
-f
Do not fold upper- to lowercase before looking up the key.
-m
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 flag 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.
-kkeycol
The key column name (for NIS+) or number (for ext lookups).
-vvalcol
The value column name (for NIS+) or number (for text lookups).
-zdelim
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.

The dbm map appends the strings .pag and .dir to the given filename. The two db-based maps append .db. For example, the following map specification:

Kuucp dbm -o -N /usr/lib/uucpmap

specifies an optional map named uucp of class dbm. It always has null bytes at the end of every string. The data is located in /usr/lib/uucpmap.[dir,pag].

The makemap(8) program can be used to build any of the three database-oriented maps. It takes the following flags:

-f
Fold upper- to lowercase in the map.
-N
Include null bytes in keys.
-o
Append to an existing (old) file.
-r
Allow replacement of existing keys. Normally, re-inserting an existing key is an error.
-v
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. File locking is used so that the maps will not be read while they are being updated.

New classes can be added in the setupmaps routine in the conf.c file.


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

The location of this database is controlled with the UserDatabaseSpec option.


Structure of the User Database

The database has a sorted (BTree-based) structure. User records are stored with the following key:

user-name:field-name

The sorted database format ensures that user records are clustered together. Meta-information is always stored with a leading colon.

Field names define both the syntax and semantics of the value. Defined fields include the following:

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.
mailname
The outgong 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.
mailsender
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 file.
fullname
The full name of the user.
office-address
The office address for this user.
office-phone
The office phone number for this user.
office-fax
The office FAX number for this user.
home-address
The home address for this user.
home-phone
The home phone number for this user.
home-fax
The home FAX number for this user.
project
A (short) description of the project with which this person is affiliated.
plan
A pointer to a file from which plan information can be gathered.

As of this writing, only a few of these fields are actually being used by Sendmail. They are maildrop and mailname. A finger program that uses the other fields is planned.


User Database Semantics

When the rewriting rules submit an address to the local mailer, the user name is passed through the alias file. 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 first token of the user name returned by rule set 0 is an @ sign, the user database lookup is skipped. The user database should act as a set of defaults for a cluster; mail sent to a specific 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 his or her outgoing name. For example, consider the following record:

eric:mailname   Eric.Allman@CS.Berkeley.EDU

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 overrider the local host. For example, in our case we would set it to CS.Berkeley.EDU. The effect is that all the users known in the database have their outgoing mail stamped as user@CS.Berkeley.EDU, but people not listed in the database use the local host name.


Creating the Database

The user database is built from a text file using the makemap utility (in the distribution in the makemap subdirectory). The text file 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 file is normally installed in a system directory; for example, it might be called /etc/userdb. To make the database version of the map, run the following program:

makemap btree /etc/userdb.db < /etc/userdb

Then create a configuration file that uses this. For example, using the V8 M4 configuration, include the following line in your .mc file;

define(`confUSERDB_SPEC', /etc/userdb.db)


Other Configuration Changes

Some configuration changes can be made by recompiling Sendmail. This section describes what changes can be made and what has to be modified to make them. In most cases any change should be unnecessary unless you are porting Sendmail to a new environment.


Parameters in src/Makefile

These parameters describe the compilation environment, not site policy, and should normally be defined in src/Makefile.

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 efficient method of alias lookup is used.
NEWDB
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 files, but will create and use NEWDB files.
NIS
Include support for NIS. If set together with both NEWDB and NDBM, Sendmail will create both DBM and NEWDB files if and only if an alias file includes the substring /yp/ in the name. This is intended for compatibility with Sun Microsystems' mkalias program used on YP masters.
NISPLUS
Compile in support for NIS+.
NETINFO
Compile in support for NetInfo (NeXTTM stations).
HESIOD
Compile in support for Hesiod.
SYSTEM5
Set all compilation parameters appropriate for System V.
LOCKF
Use System V lockf instead of Berkeley flock. Because of the highly unusual semantics of locks across forks in lockf, this should never be used unless absolutely necessary. Set by default if SYSTEM5 is set.
SYS5TZ
Use System V time zone semantics.
_PATH_SENDMAILCF
The pathname of the sendmail.cf file.
_PATH_SENDMAILPID
The pathname of the sendmail.pid file.

There are also several compilation flags to indicate the environment such as _AIX3 and _SCO_unix_. See the READ_ME file for the latest information on these flags.


Parameters in src/conf.h

Parameters and compilation options are defined 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 file. The numbers following the parameters are their default value.


NOTE

This document is not the best source of information for compilation flags in conf.h. Refer to src/READ_ME or src/conf.h.


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, configuration file lines, alias lines, and such, must fit within this limit.
MAXNAME [256]
The maximum length of any name, such as a host or a user name.
MAXPV [40]
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 the load on your system, however.
MAXATOM [100]
The maximum number of atoms (tokens) in a single address. For example, the address "eric@CS.Berkeley.EDU" is seven atoms.
MAXMAILERS [25]
The maximum number of mailers that may be defined in the configuration file.
MAXRWSETS [200]
The maximum number of rewriting sets that may be defined. The first half of these is reserved for numeric specification (for example S92), while the upper half is reserved for auto-numbering (for example, 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: field that may be defined (using the P line in sendmail.cf).
MAXUSERENVIRON [40]
The maximum number of items in the user environment that will be passed to subordinate mailers.
MAXMXHOSTS [20]
The maximum number of MX records accepted from 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-file 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).

A number of other compilation options exist. These specify whether or not specific 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 to on. Turn it off in the Makefile if your system does not support the Internet protocols.
NETINET
Compiles in support for Internet protocol networking. Previous versions of Sendmail referred to this as DAEMON. This old usage is now incorrect.
NETISO*
Compiles in support for ISO protocol networking (it may be appropriate to #define this in the Makefile instead of conf.h).
LOG
Runs the syslog routine in use at some sites. 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 configuration file.
MATCHGECOS*
Compiles in the code to do "fuzzy matching" on the GECOS field in /etc/passwd. This also requires that option MatchGECOS be turned on.
NAMED_BIND*
Compiles in code to use the Berkeley Internet Name Domain (BIND) server to resolve TCP/IP host names.
NOTUNIX
If you are using a non-UNIX mail format, you can set this flag to turn off special processing of UNIX-style From lines.
QUEUE
Compiles in the queuing code. If this flag is not set, mailers must accept the mail immediately or it will be returned to the sender.
SMTP
Compiles in the code to handle user and server SMTP. This is only necessary if your machine has some mailer that speaks SMTP (this means most machines).
USERDB*
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.

The following options are normally turned on in per-operating-system clauses in conf.h.

IDENTPROTO
Compiles in the IDENT protocol as defined in RFC 1413. This defaults to "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 firewall gateways send this error code when you access an unauthorized port (such as 113, used by IDENT), ULTRIX cannot receive E-mail from such hosts.
HASFLOCK*
Use the Berkeley-style flock instead of System V lockf to do the file locking. Because of the highly unusual semantics of locks across forks in lockf, always use flock.
HASTINITGROUPS
Set this if your system has the initgroups() call (if you have multiple group support). This is the default if SYSTEM5 is not defined 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 if you have the haswaitpid(2) system call.
SFS_TYPE
The mechanism that can be used to get file system capacity information. The values can be one of SFS_USTAT (use the ustat(2) system call), SFS_4ARGS (use the four-argument statfs(2) system call), SFS_VFS (use the two-argument statfs(2) system call including <sys/vfs.h>), SFS_MOUNT (use the two-argument statfs(2) system call including <sys/statfs.h>), SFS_STATFS (use the two-argument statfs(2)

system call including <sys/statvfs.h>), SFS_STATVFS (use the two-argument statfs(2) system call including <sys/statvfs.h>), or SFS_NONE.

LA_TYPE
The load average type. Details are described below.

There are several built-in ways of computing the load average. Sendmail tries to auto-configure them based on imperfect guesses. You can select one by using the cc option -DLA_TYPE=type, where type is:

LA_INT
The kernel stores the load average in kernel memory as an array of long integers. The actual values are scaled by a factor FSCALE (default 256).
LA_SHORT
The kernel stores the load average in kernel memory as an array of short integers. The actual values are scaled by a factor FSCALE (default 256).
LA_FLOAT
The kernel stores the load average in kernel memory as an array of double-precision floats.
LA_MACH
Use MACH-style load averages.
LA_SUBR
Call the getloadavg routine to get the load average as an array of doubles.
LA_ZERO
Always return zero as the load average. This is the fallback case.

If type LA_INT, LA_SHORT or LA_FLOAT is specified, 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).


Configuration in src/conf.c

The following changes can be made in conf.c.


Built-in Header Semantics

Not all header semantics are defined in the configuration file. Header lines that should only be included by certain mailers (as well as other more obscure semantics) must be specified in the HdrInfo table in conf.c. This table contains the header name (which should be in lower case) and a set of header control flags (described below). The flags are as follows:

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 flag is set, Sendmail will delete even existing header lines. That is, if this bit is set and the mailer does not have flag bits set that intersect with the required mailer flags in the header definition in sendmail.cf, the header line is always deleted.
H_EOH
If this header field is set, treat it like a blank line; that is, it will signal the end of the header and the beginning of the message text.
H_FORCE
Add this header entry even if one existed in the message before. This would normally be used to stamp the message by everyone who handled it.
H_TRACE
If set, this is a timestamp (trace) field. If the number of trace fields in a message exceeds a preset amount, the message is returned on the assumption that it has an aliasing loop.
H_RCPT
If set, this field contains recipient addresses. This is used by the -t flag to determine who to send to when it is collecting recipients from the message.
H_FROM
This flag indicates that this field specifies a sender. The order of these fields in the HdrInfo table specifies Sendmail's preference for which field to return error messages to.
H_ERRORSTO
Addresses in this header should receive error messages.
H_CTE
This header is a Content-Transfer-Encoding header
H_CTYPE
This header is a Content-Type header
H_STRIPVAL
Strip the value from the header (for Bcc:).

Consider the following sample HdrInfo specification:

struct hdrinfo   HdrInfo[] =
{
          /* originator fields, most to least significant  */
     "resent-sender",           H_FROM,
     "resent-from",             H_FROM,
     "sender",                  H_FROM,
     "from",                    H_FROM,
     "full-name",               H_ACHECK,
     ``error-to'',                H_FROM|ERRORSTO,
          /* destination fields */
     "to",                      H_RCPT,
     "resent-to",               H_RCPT,
     "cc",                      H_RCPT,
     "bcc",                     H_RCPT|H_STRIPVAL
          /* message identification and control */
    "message",                  H_EOH,
    "text",                     H_EOH,
          /* trace fields */
    "received",                 H_TRACE|H_FORCE,
          /* miscellaneous fields */
   ``content-transfer-encoding'', H_CTE.
   ``content-type''.              H_CTYPE,

    NULL,                       0,
};

This structure indicates that the To:, Resent-To:, and Cc: fields all specify recipient addresses. Any Full-Name: field will be deleted unless the required mailer flag (indicated in the configuration file) is specified. The Message: and Text: fields will terminate the header. These are used by random dissenters around the network world. The Received: field will always be added, and can be used to trace messages.

There are a number of important points here. First, header fields are not added automatically just because they are in the HdrInfo structure; they must be specified in the configuration file in order to be added to the message. Any header fields mentioned in the configuration file 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 specifies cliched processing; that is, certain headers are processed specially by ad hoc code regardless of the status specified in HdrInfo. For example, the Sender: and From: fields are always scanned on ARPANET mail to determine the sender; this is used to perform the "return to sender" function. The From: and Full-Name: fields 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.


Restricting Use of E-mail

If it is necessary to restrict mail through a relay, the checkcompat routine can be modified. 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 as follows:

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_flags|=EF_NORETURN;
                return (EX_UNAVAILABLE);
        }         return (EX_OK);
}

This would reject messages greater than 50000 bytes unless they were local. The EF_NORETURN flag can be set in e->e_flags 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.


Load Average Computation

The getla routine should return an approximation of the current system load average as an integer. There are four versions included on compilation flags as described above.


New Database Map Classes

The new key maps can be added by creating a class initialization function and a lookup function. These are then added to the setupmaps routine.

The initialization function is called as

xxx _map_init(MAP *map, char *mapname, char *args)

The map is an internal data structure. The mapname is the name of the map (used for error messages). The args is a pointer to the rest of the configuration file line. Flags and filenames can be extracted from this line. The initialization function must return TRUE if it successfully opened the map, FALSE otherwise.

The lookup function is called as

xxx _map_lookup(MAP *map, char buf[], int bufsize, char **av,int *statp)

The map defines the map internally. The buf and bufsize parameters have 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.


Queuing Function

The shouldqueue routine is called to decide if a message should be queued or processed immediately. Typically, this compares the message priority with the current load average. The default definition is as follows:

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), shouldqueuereturns FALSE immediately (that is, it should not queue). If the current load average exceeds the high threshold load average (option X, variable RefuseLA), shouldqueuereturns 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 first 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.


Refusing Incoming SMTP Connections

The refuseconnections function 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 (CurrentLA >= RefuseLA);
}

A cleverer implementation could look at more system resources.


Load Average Computation

The getla routine returns the current load average (as a rounded integer). The distribution includes several possible implementations.


Configuration in src/daemon.c

The file src/daemon.c contains a number of routines that are dependent on the local networking environment. The version supplied assumes that you have BSD style sockets.

In previous releases, it was recommended that you modify the routine maphostname if you wanted to generalize $[ ...$] lookups. Now it is recommended that you create a new keyed map instead.


Changes in Version 8

The following sections summarize the changes since the last commonly available version of Sendmail (5.67).


Connection Caching

Instead of being closed immediately, SMTP connections are cached for possible future use. The advent of MX records made this effective for mailing lists. In addition, substantial performance improvements can be expected for queue processing.


MX Piggybacking

If two hosts with different names in a single message happen to have the same set of MX hosts, they can be sent in the same transaction. Version 8 notices this possibility and tries to batch the messages.


RFC 1123 Compliance

A number of changes have been made to make Sendmail "conditionally compliant" (that is, Sendmail satisfies all of the "MUST" clauses and most but not all of the "SHOULD" clauses in RFC 1123).

The major areas of change are (numbers are RFC 1123 section numbers):

5.2.7
Response to RCPT command is fast.
5.2.8
Numeric IP addresses are logged in Received: lines.
5.2.17
Self domain literal is properly handled.
5.3.2
Better control over individual timeouts.
5.3.3
Error messages are sent as From:<>.
5.3.3
Error messages are never sent to <>.
5.3.3
Route-addresses are pruned.

The areas in which Sendmail is not "unconditionally compliant" are as follows:

5.2.6
Sendmail does do header manipulation.
5.2.10
Sendmail does not always use the exact SMTP message text as listed in RFC 821.
5.3.1.1
Sendmail does not guarantee only one connect for each host in queue runs.
5.3.1.1
Sendmail does not always provide adequate concurrency limits.

Extended SMTP Support

Version 8 includes both sending and receiving support for Extended SMTP (ESMTP) as defined by RFC 1425 (basic) and RFC 1427 (SIZE), and limited support for RFC 1425 (BODY).


Eight-Bit Clean

Previous versions of Sendmail used the 0200 bit for quoting. This version avoids that use. However, for compatibility with RFC 822, you can set option 7 to get 7-bit stripping.

Individual mailers can still produce 7-bit output using the 7 mailer flag.


User Database

The user database is still an experimental attempt to provide unified large-site name support. Future versions may show significant modification.


Improved BIND Support

The BIND support, particularly for MX records, had a number of annoying features that have been removed in this release. In particular, these more tightly bind the name server to Sendmail, so that the name server resolution rules are incorporated directly into Sendmail.


Keyed Files

Generalized keyed files is an idea taken directly from IDA Sendmail (albeit with a completely different implementation). They can be useful on large sites.

Version 8 also understands YP.


Multi-Word Classes

Classes can now be multiple words as in the following example:

CShofmann.CS.Berkeley.EDU

In this example, you can match the entire string hofman.CS.Berkeley.EDU using the single construct $=S.


Deferred Macro Expansion

The $&x construct has been adopted from IDA.


IDENT Protocol Support

The IDENT protocol as defined in RFC 1413 is supported.


Parsing Bug Fixes

A number of small bugs dealing with such things as backslash-escaped quotes inside of comments have been fixed.


Separate Envelope/Header Processing

Since the From: line is passed in separately from the envelope sender, these have both been made visible. The $g macro is set to the envelope sender during processing of mailer argument vectors and the header sender during processing of headers.

You can also specify separate per-mailer envelope and header processing. The SenderRWSet and RecipientRWset arguments for mailers can be specified as envelope/header to give different rewritings for envelope versus header addresses.


Owner-List Propagates to Envelope

When an alias has an associated owner-list name, that alias is used to change the envelope sender address. This will cause downstream errors to be returned to that owner.


Dynamic Header Allocation

The fixed size limit on header lines has been eliminated.


New Command Line Flags

The -B flag has been added to pass in body type information.

The -p flag has been added to pass in protocol information.

The -X flag has been added to allow logging of all protocol in and out of Sendmail for debugging.


Enhanced Command Line Flags

The -q flag can limit a queue run to specific recipients, senders, or queue IDs using -qRsubstring, -qSsubstring, or -qIsubstring respectively.


New and Old Configuration Line Types

The K line has been added to declare database maps.

The V line has been added to declare the configuration version level.

The M line has a D= field that lets you change into a temporary directory while that mailer is running.


New Options

Several new options have been added, many to support new features, others to allow tuning that was previously available only by recompiling. They are described earlier in the section entitled "H - Define Header" and are briefly described in the following list:

b
Insist on a minimum number of disk blocks.
C
Set checkpoint interval.
E
Default error message.
G
Enable GECOS matching.
h
Maximum hop count.
j
Send errors in MIME-encapsulated format.
J
Forward file path.
k
Connection cache size.
K
Connection cache lifetime.
l
Enable Errors-To: header. These headers violate RFC 1123. This option is included to provide back compatibility with old versions of Sendmail.
O
Set incoming SMTP daemon options, such as an alternate SMTP port.
p
Privacy options.
R
Do not prune route-addresses.
U
User database spec.
V
Fallback MX host.
w
Best MX handling technique.
7
Does not run 8-bit clean.
8

eight bit data handling mode.


Extended Options

The r (read timeout), I (use BIND), and T (queue timeout) options have been extended to pass in more information.


New Mailer Flags

The following new mailer flags have been added:

a
Try to use ESMTP when creating a connection. If this is not set, Sendmail will still try if the other end hints that it knows about ESMTP in its greeting message. This flag says to try even if it does not hint. If the EHLO (extended HELO) command fails, Sendmail falls back to the old SMTP.
b
Ensure that there is a blank line at the end of all messages.
c
Strip all comments from addresses. This should only be used as a last resort when dealing with some difficult mailers.
g
Never use the null sender as the envelope sender, even when running SMTP. Although this violates RFC 1123, it may be necessary when you must deal with some old hosts.
k
Turn off the loopback check in the HELO protocol; doing this may cause mailer loops.
o
Always run the mailer as the recipient of the message.
w
This user should have a password file entry
5
Try rule set 5 if there are no local aliases.
7
Strip all output to seven bits.
:
Check for :include: files.
|
Check for |program addresses.
/
Check for /file addresses.
@
Check this user against the user database.

Long Option Names

All options can be specified by using long names, and some new options can only be specified with long names.


New Pre-Defined Macros

The following macros are pre-defined:

$k
The UUCP node name, nominally from the uname(2) call.
$m
The domain part of our full host name.
$_
The RFC 1413-provided sender address.

New LHS Token

Version 8 allows $@ on the Left-Hand Side of an R line to match zero tokens. This is used to match the null input.


Bigger Defaults

Version 8 allows up to 100 rule sets instead of 30. It is recommended that rule sets 0-9 be reserved for Sendmail's dedicated use in future releases.

The total number of MX records that can be used has been raised to 20.

The number of queued messages that can be handled at one time has been raised from 600 to 1000.


Different Default Tuning Parameters

Version 8 has changed the default parameters for tuning queue costs to make the number of recipients more important than the size of the message (for small messages). This is reasonable if you are connected with reasonably fast links.


Auto-Quoting in Addresses

Previously, the "Full Name <email address>" syntax would generate incorrect protocol output if Full Name had special characters such as a dot. This version puts quotes around such names.


Symbolic Names on Error Mailer

Several names have been built in to the $@ portion of the $#error mailer.


SMTP VRFY Does Not Expand

Previous versions of Sendmail treated VRFY and EXPN the same. In this version, VRFY does not expand aliases or follow .forward files. EXPN still does.

As an optimization, if you run with your default delivery mode being queue-only or deliver-in-background, the RCPT command will also not chase aliases and .forward files. It will chase them when it processes the queue.


[IPC] Mailers Allow Multiple Hosts

When an address resolves to a mailer that has [IPC] as its Path, the $@ part (host name) can be a colon-separated list of hosts instead of a single host name. This asks Sendmail to search the list for the first entry that is available exactly as though it were an MX record. The intent is to route internal traffic through internal networks with out publishing an MX record to the net. MX expansion is still done on individual terms.


Aliases Extended

The implementation has been merged with maps. Among other things, this supports NIS-based aliases.


Portability and Security Enhancements

A number of internal changes have been made to enhance portability.

Several fixes have been made to increase the paranoia factor.


Miscellaneous Changes

Sendmail writes a /etc/sendmail.pid file with the current process ID of the SMTP daemon.

Two people using the same program in their .forward file are considered different so that duplicate elimination does not delete one of them.

The mailstats program prints mailer names and gets the location of the sendmail.st file from /usr/lib/sendmail.cf.

Many minor bugs have been fixed, such as handling of backslashes inside End of File (EOF) quotes.

A hook (rule set 5) has been added to allow rewriting of local addresses after aliasing.


Command Line Flags

Arguments must be presented with flags before addresses. The flags are explained in the following list:

-bx
Sets operation mode to x. Operation modes are:

m - Delivers mail (default).

s - Speaks SMTP on input side.

a* - "Arpanet" mode (get envelope sender information from header)

d - Runs as a daemon.

t - Runs in test mode.

v - Verifies addresses, do not collect or deliver.

i - Initializes the alias database.

p - Prints the mail queue.

-Btype
Indicates body type.
-Cfile
Uses a different configuration file. Sendmail runs as the invoking user (rather than root) when this flag is specified.
-dlevel
Sets the debugging level.
f addr
The sender's machine address is addr.
-Fname
Sets the full name of this user to name.
-h cnt
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.
-n
Does not do aliasing or forwarding.
-r addr
An obsolete form of -f.
-oxvalue
Sets option x to the specified value. These options are described in the section entitled "0 - Set Option".
-Ooption= value
Sets option to the specified value. These options are described in the section entitled "0 - Set Option".
pprotocol
Sets the sending protocol. Programs are encouraged to set this. The protocol field 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.)
-qtime
Tries to process the queued up mail. If the time is given, Sendmail will run through the queue at the specified interval to deliver queued mail; otherwise, it only runs once.
-qXstring
Runs the queue once, limiting the jobs to those matching Xstring. The key letter X can be I to limit based on queue identifier, 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.
-t
Reads 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.
X logfile
Logs all traffic in and out of Sendmail in the indicated logfile for debugging mailer problems. This produces a lot of data very quickly and should be used sparingly.

The e, i, m, and v options may be specified as primitive flags. Also, the f option may be specified as the -s flag.


Queue File Formats

This appendix describes the format of the queue files. These files live in the directory defined by the Q option in the sendmail.cf file, usually /var/spool/mqueue or /usr/spool/mqueue.

All queue files have the name xfAAA99999 where AAA99999 is the ID for this message and the x is a type. The first letter of the ID encodes the hour of the day that the message was received by the system (with A being the hour between midnight and 1:00 AM). all files with the same ID collectively define on message.

The types are described in the following list:

d
The data file. The message body (excluding the header is kept in this file.
q
The queue control file. This file contains the information necessary to process the job.
t
A temporary file. These are an image of the qf file when it is being rebuilt. It should be renamed to a qf file very quickly.
x
A transcript file, existing during the life of a session showing everything that happens during that session.

The qf file 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 file format, used to allow new Sendmail binaries to read queue files created by older versions. Defaults to version zero. Must be the first line of the file if present.
H
A header definition. There may be any number of these lines. The order is important. They represent the order in the final message. These use the same syntax as header definitions in the configuration file.
C
The controlling address. The syntax is localuser:aliasname. Recipient addresses following this line will be flagged so that deliveries will be run as the localuser (a user name from the /etc/passwd file). aliasname is the name of the alias that expanded to this address (used for printing messages).
Q
The "original recipient", specified by the ORCPT= field in an ESMTP transaction. Used exclusively for Delivery Status Notifications. It applies only to the immediately following R line.
R
A recipient address. This will normally be completely aliased, but it is actually re-aliased when the job is processed. There is one line for each recipient. Version 1 qf files also include a leading colon-terminated list of flags, which can be S to return a message on successful final 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.
S
The sender address. There can be only one of these lines.
T
The job creation time. This is used to compute when to time out the job.
P
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.
M
A message. This line is printed by the mailq command and is generally used to store status information. It can contain any text.
F
Flag bits, represented as on letter per flag. Defined flag bits are r, indicating that this is a response message, and w, indicating that a warning message has been sent to announce that the mail has been delayed.
N
The total number of delivery attempts.
K
The time (as seconds since January 1, 1970) of the last delivery attempt.
I
The "i-number" of the data file. This can be used to recover your mail queue after a disastrous disk crash.
$
A macro definition. The values of certain macros (such as $r and $s) are passed through to the queue run phase.
B
The body type. The remainder of the line is a text string defining the body type. If this field is missing, the body type is assumed to be "undefined" and no special processing is attempted. Legal values are 7BIT and 8BITMIME.

As an example, the following is a queue file that is sent to eric@mammoth.Berkeley.EDU and bostic@okeefe.CS.Berkeley.EDU:

P835771
T404261372
Seric Ceric:sendmail@vangogh.CS.Berkeley.EDU
Reric@mammoth.Berkeley.EDU
Rbostic@okeeffe.CS.Berkeley.EDU
H?P?return-path: <owner-sendmail@vangogh.CS.Berkeley.EDU>
Hreceived: by vangogh.CS.Berkeley.EDU (5.108/2.7) id AAA06703;
        Fri, 17 Jul 92 00:28:55 -0700
Hreceived: from mail.CS.Berkeley.EDU by vangogh.CS.Berkeley.EDU (5.108/2.7)
        id AAA06698; Fri, 17 Jul 92 00:28:54 -0700
Hreceived: from [128.32.31.21] by mail.CS.Berkeley.EDU (5.96/2.5)
        id AA22777; Fri, 17 Jul 92 03:29:14 -0400
Hreceived: by foo.bar.baz.de (5.57/Ultrix3.0-C)
        id AA22757; Fri, 17 Jul 92 09:31:25 GMT
H?F?from: eric@foo.bar.baz.de (Eric Allman)
H?x?full-name: Eric Allman
Hmessage-id: <9207170931.AA22757@foo.bar.baz.de>
HTo: sendmail@vangogh.CS.Berkeley.EDU
Hsubject: this is an example message

This shows the name of the data file, 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.


Summary of Support Files

This is a summary of the support files that Sendmail creates or generates.

/usr/lib/sendmail
The binary of Sendmail.
/usr/lib/newaliases
A link to/usr/lib/sendmail causes the alias database to be rebuilt. Running this program is completely equivalent to giving Sendmail the -bi flag.
/usr/lib/mailq
Prints a listing of the mail queue. This program is equivalent to using the -bp flag with Sendmail.
/etc/mail/sendmail.cf
The configuration file, in textual form.
/etc/mail/sendmail.hf
The SMTP help file.
/usr/lib/sendmail.st
A statistics file. It need not be present.
/usr/lib/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 first line. Later versions of Sendmail may add information to subsequent lines.
/etc/mail/aliases
The textual version of the alias file.
/etc/mail/aliases.{pag,dir}
The alias file in dbm(3) format.
/var/spool/mqueue
The directory in which the mail queue and temporary files reside.
/var/spool/mqueue/qf*
Control (queue) files for messages.
/var/spool/mqueue/df*
Data files.
/var/spool/mqueue/tf*
Temporary versions of the qf files, used during queue file rebuilding.
/var/spool/mqueue/xf*
A transcript of the current session.