Sendmail Installation and Operation Guide
Sendmail Installation and Operation Guide
Eric Allman
Sendmail, Inc.
[email protected]
Version 8.317.4.56
SendmailTM implements a general purpose internetwork mail routing facility under the UNIX® oper-
ating system. It is not tied to any one transport protocol — its function may be likened to a crossbar switch,
relaying messages from one domain into another. In the process, it can do a limited amount of message
header editing to put the message into a format that is appropriate for the receiving domain. All of this is
done under the control of a configuration file.
Due to the requirements of flexibility for sendmail, the configuration file can seem somewhat unap-
proachable. However, there are only a few basic configurations for most sites, for which standard configu-
ration files have been supplied. Most other configurations can be built by adjusting an existing configura-
tion file incrementally.
Sendmail is based on RFC821 (Simple Mail Transport Protocol), RFC822 (Internet Mail Headers
Format), RFC974 (MX routing), RFC1123 (Internet Host Requirements), RFC2045 (MIME), RFC1869
(SMTP Service Extensions), RFC1652 (SMTP 8BITMIME Extension), RFC1870 (SMTP SIZE Extension),
RFC1891 (SMTP Delivery Status Notifications), RFC1892 (Multipart/Report), RFC1893 (Enhanced Mail
System Status Codes), RFC1894 (Delivery Status Notifications), RFC1985 (SMTP Service Extension for
Remote Message Queue Starting), RFC2033 (Local Message Transmission Protocol), RFC2034 (SMTP
Service Extension for Returning Enhanced Error Codes), RFC2476 (Message Submission), RFC2487
(SMTP Service Extension for Secure SMTP over TLS), and RFC2554 (SMTP Service Extension for
Authentication). However, since sendmail is designed to work in a wider world, in many cases it can be
configured to exceed these protocols. These cases are described herein.
Although sendmail is intended to run without the need for monitoring, it has a number of features
that may be used to monitor or adjust the operation under unusual circumstances. These features are
described.
Section one describes how to do a basic sendmail installation. Section two explains the day-to-day
information you should know to maintain your mail system. If you have a relatively normal site, these two
sections should contain sufficient information for you to install sendmail and keep it happy. Section three
describes some parameters that may be safely tweaked. Section four has information regarding the com-
mand line arguments. Section five contains the nitty-gritty information about the configuration file. This
section is for masochists and people who must write their own configuration file. Section six describes con-
figuration that can be done at compile time. The appendixes give a brief but detailed explanation of a
1. BASIC INSTALLATION
There are two basic steps to installing sendmail. First, you have to compile and install the binary.
If sendmail has already been ported to your operating system that should be simple. Second, you must
build a run-time configuration file. This is a file that sendmail reads when it starts up that describes the
mailers it knows about, how to parse addresses, how to rewrite the message header, and the settings of
various options. Although the configuration file can be quite complex, a configuration can usually be
built using an M4-based configuration language.
The remainder of this section will describe the installation of sendmail assuming you can use one
of the existing configurations and that the standard installation parameters are acceptable. All path-
names and examples are given from the root of the sendmail subtree, normally /usr/src/usr.sbin/send-
mail on 4.4BSD.
If you are loading this off the tape, continue with the next section. If you have a running binary
already on your system, you should probably skip to section 1.2.
These files also assume that most of your neighbors use domain-based UUCP addressing; that
is, instead of naming hosts as “host!user” they will use “host.domain!user”. The configuration files
can be customized to work around this, but it is more complex.
Our configuration files are processed by m4 to facilitate local customization; the directory cf
of the sendmail distribution directory contains the source files. This directory contains several sub-
directories:
cf Both site-dependent and site-independent descriptions of hosts. These can be lit-
eral host names (e.g., “ucbvax.mc”) when the hosts are gateways or more general
descriptions (such as “generic-solaris2.mc” as a general description of an SMTP-
connected host running Solaris 2.x. Files ending .mc (‘‘Master Configuration’’)
are the input descriptions; the output is in the corresponding .cf file. The general
structure of these files is described below.
domain Site-dependent subdomain descriptions. These are tied to the way your organiza-
tion wants to do addressing. For example, domain/CS.Berkeley.EDU.m4 is our
description for hosts in the CS.Berkeley.EDU subdomain. These are referenced
using the DOMAIN m4 macro in the .mc file.
feature Definitions of specific features that some particular host in your site might want.
These are referenced using the FEATURE m4 macro. An example feature is
use_cw_file (which tells sendmail to read an /etc/mail/local-host-names file on
startup to find the set of local names).
hack Local hacks, referenced using the HACK m4 macro. Try to avoid these. The
point of having them here is to make it clear that they smell.
m4 Site-independent m4(1) include files that have information common to all configu-
ration files. This can be thought of as a “#include” directory.
mailer Definitions of mailers, referenced using the MAILER m4 macro. The mailer types
that are known in this distribution are fax, local, smtp, uucp, and usenet. For
example, to include support for the UUCP-based mailers, use “MAILER(uucp)”.
ostype Definitions describing various operating system environments (such as the loca-
tion of support files). These are referenced using the OSTYPE m4 macro.
sh Shell files used by the m4 build process. You shouldn’t have to mess with these.
siteconfig Local UUCP connectivity information. This directory has been supplanted by the
mailertable feature; any new configurations should use that feature to do UUCP
(and other) routing.
If you are in a new domain (e.g., a company), you will probably want to create a cf/domain
file for your domain. This consists primarily of relay definitions and features you want enabled site-
wide: for example, Berkeley’s domain definition defines relays for BitNET and UUCP. These are
specific to Berkeley, and should be fully-qualified internet-style domain names. Please check to
make certain they are reasonable for your domain.
Subdomains at Berkeley are also represented in the cf/domain directory. For example, the
domain CS.Berkeley.EDU is the Computer Science subdomain, EECS.Berkeley.EDU is the Electri-
cal Engineering and Computer Sciences subdomain, and S2K.Berkeley.EDU is the Sequoia 2000
subdomain. You will probably have to add an entry to this directory to be appropriate for your
domain.
You will have to use or create .mc files in the cf/cf subdirectory for your hosts. This is
detailed in the cf/README file.
SMM:08-10 Sendmail Installation and Operation Guide
1.3.1. /usr/sbin/sendmail
The binary for sendmail is located in /usr/sbin1. It should be setuid root. For security rea-
sons, /, /usr, and /usr/sbin should be owned by root, mode 7552.
1.3.2. /etc/mail/sendmail.cf
This is the configuration file for sendmail3. This is the only non-library file name com-
piled into sendmail4.
The configuration file is normally created using the distribution files described above. If
you have a particularly unusual system configuration you may need to create a special version.
The format of this file is detailed in later sections of this document.
1.3.3. /usr/bin/newaliases
The newaliases command should just be a link to sendmail:
rm −f /usr/bin/newaliases
ln −s /usr/sbin/sendmail /usr/bin/newaliases
This can be installed in whatever search path you prefer for your system.
1.3.4. /usr/bin/hoststat
The hoststat command should just be a link to sendmail, in a fashion similar to
newaliases. This command lists the status of the last mail transaction with all remote hosts.
The −v flag will prevent the status display from being truncated. It functions only when the
HostStatusDirectory option is set.
1.3.5. /usr/bin/purgestat
This command is also a link to sendmail. It flushes expired (Timeout.hoststatus) informa-
tion that is stored in the HostStatusDirectory tree.
1.3.6. /var/spool/mqueue
The directory /var/spool/mqueue should be created to hold the mail queue. This directory
should be mode 700 and owned by root.
The actual path of this directory is defined in the Q option of the sendmail.cf file. To use
multiple queues, supply a value ending with an asterisk. For example, /var/spool/mqueue/qd*
will use all of the directories or symbolic links to directories beginning with ‘qd’ in
/var/spool/mqueue as queue directories. Do not change the queue directory structure while
1
This is usually /usr/sbin on 4.4BSD and newer systems; many systems install it in /usr/lib. I understand it is in /usr/ucblib on
System V Release 4.
2
Some vendors ship them owned by bin; this creates a security hole that is not actually related to sendmail. Other important di-
rectories that should have restrictive ownerships and permissions are /bin, /usr/bin, /etc, /etc/mail, /usr/etc, /lib, and /usr/lib.
3
Actually, the pathname varies depending on the operating system; /etc/mail is the preferred directory. Some older systems in-
stall it in /usr/lib/sendmail.cf, and I’ve also seen it in /usr/ucblib. If you want to move this file, add -D_PATH_SENDMAIL-
CF=\"/file/name\" to the flags passed to the C compiler. Moving this file is not recommended: other programs and scripts know of this
location.
4
The system libraries can reference other files; in particular, system library subroutines that sendmail calls probably reference
/etc/passwd and /etc/resolv.conf.
Sendmail Installation and Operation Guide SMM:08-11
sendmail is running.
If these directories have subdirectories or symbolic links to directories named ‘qf’, ‘df’,
and ‘xf’, then these will be used for the different queue file types. That is, the data files are
stored in the ‘df’ subdirectory, the transcript files are stored in the ‘xf’ subdirectory, and all oth-
ers are stored in the ‘qf’ subdirectory.
1.3.7. /var/spool/mqueue/.hoststat
This is a typical value for the HostStatusDirectory option, containing one file per host
that this sendmail has chatted with recently. It is normally a subdirectory of mqueue.
1.3.8. /etc/mail/aliases*
The system aliases are held in “/etc/mail/aliases”. A sample is given in “sendmail/aliases”
which includes some aliases which must be defined:
cp lib/aliases /etc/mail/aliases
edit /etc/mail/aliases
You should extend this file with any aliases that are apropos to your system.
Normally sendmail looks at a database version of the files, stored either in
“/etc/mail/aliases.dir” and “/etc/mail/aliases.pag” or “/etc/mail/aliases.db” depending on which
database package you are using. The actual path of this file is defined in the AliasFile option of
the sendmail.cf file.
1.3.10. /etc/mail/helpfile
This is the help file used by the SMTP HELP command. It should be copied from “send-
mail/helpfile”:
SMM:08-12 Sendmail Installation and Operation Guide
#!/bin/sh
# remove zero length qf files
for qffile in qf*
do
if [ −r $qffile ]
then
if [ ! −s $qffile ]
then
echo −n " <zero: $qffile>" > /dev/console
rm −f $qffile
fi
fi
done
# rename tf files to be qf if the qf does not exist
for tffile in tf*
do
qffile=‘echo $tffile | sed ’s/t/q/’‘
if [ −r $tffile −a ! −f $qffile ]
then
echo −n " <recovering: $tffile>" > /dev/console
mv $tffile $qffile
else
if [ −f $tffile ]
then
echo −n " <extra: $tffile>" > /dev/console
rm −f $tffile
fi
fi
done
# remove df files with no corresponding qf files
for dffile in df*
do
qffile=‘echo $dffile | sed ’s/d/q/’‘
if [ −r $dffile −a ! −f $qffile ]
then
echo −n " <incomplete: $dffile>" > /dev/console
mv $dffile ‘echo $dffile | sed ’s/d/D/’‘
fi
done
# announce files that have been saved during disaster recovery
for xffile in [A-Z]f*
do
if [ −f $xffile ]
then
echo −n " <panic: $xffile>" > /dev/console
fi
done
cp sendmail/helpfile /etc/mail/helpfile
The actual path of this file is defined in the HelpFile option of the sendmail.cf file.
1.3.11. /etc/mail/statistics
If you wish to collect statistics about your mail traffic, you should create the file
“/etc/mail/statistics”:
cp /dev/null /etc/mail/statistics
chmod 644 /etc/mail/statistics
This file does not grow. It is printed with the program “mailstats/mailstats.c.” The actual path
of this file is defined in the S option of the sendmail.cf file.
1.3.12. /usr/bin/mailq
If sendmail is invoked as “mailq,” it will simulate the −bp flag (i.e., sendmail will print
the contents of the mail queue; see below). This should be a link to /usr/sbin/sendmail.
2. NORMAL OPERATIONS
2.1.1. Format
Each line in the system log consists of a timestamp, the name of the machine that gener-
ated it (for logging from several machines over the local area network), the word “sendmail:”,
and a message6. Most messages are a sequence of name=value pairs.
The two most common lines are logged when a message is processed. The first logs the
receipt of a message; there will be exactly one of these per message. Some fields may be omit-
ted if they do not contain interesting information. Fields are:
from The envelope sender address.
size The size of the message in bytes.
class The class (i.e., 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 for-
warding).
msgid The message id of the message (from the header).
proto The protocol used to receive this message (e.g., ESMTP or UUCP)
daemon The daemon name from the DaemonPortOptions setting.
relay The machine from which it was received.
There is also one line logged per delivery attempt (so there can be several per message if deliv-
ery is deferred or there are multiple recipients). Fields are:
5
Except on Ultrix, which does not support facilities in the syslog.
6
This format may vary slightly if your vendor has changed the syntax.
SMM:08-14 Sendmail Installation and Operation Guide
2.1.2. Levels
If you have syslogd (8) or an equivalent installed, you will be able to do logging. There is
a large amount of information that can be logged. The log is arranged as a succession of levels.
At the lowest level only extremely strange situations are logged. At the highest level, even the
most mundane and uninteresting events are recorded for posterity. As a convention, log levels
under ten are considered generally “useful;” log levels above 64 are reserved for debugging pur-
poses. 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 4.6.
7
This is the usual value of the HostStatusDirectory option; it can, of course, go anywhere you like in your filesystem.
SMM:08-16 Sendmail Installation and Operation Guide
indicate the host name, the last access, and the status of that access. An asterisk in the left most col-
umn indicates that a sendmail process currently has the host locked for mail delivery.
The disk based connection information is treated the same way as memory based connection
information for the purpose of timeouts. By default, information about host failures is valid for 30
minutes. This can be adjusted with the Timeout.hoststatus option.
The connection information stored on disk may be expired at any time with the purgestat
command or by invoking sendmail with the −bH switch. The connection information may be
viewed with the hoststat command or by invoking sendmail with the −bh switch.
8
HP-UX 10 has service switch support, but since the APIs are apparently not available in the libraries sendmail does not use the
native service switch in this release.
Sendmail Installation and Operation Guide SMM:08-17
will not have the desired effect (except on prep.ai.MIT.EDU, and they probably don’t want me)9.
Aliases may be continued by starting any continuation lines with a space or a tab or by putting a
backslash directly before the newline. Blank lines and lines beginning with a sharp sign (“#”) are
comments.
The second form is processed by the ndbm (3)10 or the Berkeley DB library. This form is in
the file /etc/mail/aliases.db (if using NEWDB) or /etc/mail/aliases.dir and /etc/mail/aliases.pag (if
using NDBM). This is the form that sendmail actually uses to resolve aliases. This technique is
used to improve performance.
The control of search order is actually set by the service switch. Essentially, the entry
O AliasFile=switch:aliases
is always added as the first alias entry; also, the first alias file name without a class (e.g., without
“nis:” on the front) will be used as the name of the file for a ‘‘files’’ entry in the aliases switch. For
example, if the configuration file contains
O AliasFile=/etc/mail/aliases
and the service switch contains
aliases nis files nisplus
then aliases will first be searched in the NIS database, then in /etc/mail/aliases, then in the NIS+
database.
You can also use NIS-based alias files. For example, the specification:
O AliasFile=/etc/mail/aliases
O AliasFile=nis:[email protected]
will first search the /etc/mail/aliases file and then the map named “mail.aliases” in “my.nis.domain”.
Warning: if you build your own NIS-based alias files, be sure to provide the −l flag to makedbm(8)
to map upper case letters in the keys to lower case; otherwise, aliases with upper case letters in their
names won’t match incoming addresses.
Additional flags can be added after the colon exactly like a K line — for example:
O AliasFile=nis:−N [email protected]
will search the appropriate NIS map and always include null bytes in the key. Also:
O AliasFile=nis:−f [email protected]
will prevent sendmail from downcasing the key before the alias lookup.
9
Actually, any mailer that has the ‘A’ mailer flag set will permit aliasing; this is normally limited to the local mailer.
10
The gdbm package does not work.
SMM:08-18 Sendmail Installation and Operation Guide
database, there is a chance that several processes will start the rebuild process simultaneously.
If you have multiple aliases databases specified, the −bi flag rebuilds all the database
types it understands (for example, it can rebuild NDBM databases but not NIS databases).
11
The AliasWait option is required in the configuration for this action to occur. This should normally be specified.
Sendmail Installation and Operation Guide SMM:08-19
For example, if the home directory for user “mckusick” has a .forward file with contents:
mckusick@ernie
kirk@calder
then any mail arriving for “mckusick” will be redirected to the specified accounts.
Actually, the configuration file defines a sequence of filenames to check. By default, this is
the user’s .forward file, but can be defined to be more generally using the ForwardPath option. If
you change this, you will have to inform your user base of the change; .forward is pretty well incor-
porated into the collective subconscious.
2.9.1. Errors-To:
If errors occur anywhere during processing, this header will cause error messages to go to
the listed addresses. This is intended for mailing lists.
The Errors-To: header was created in the bad old days when UUCP didn’t understand the
distinction between an envelope and a header; this was a hack to provide what should now be
passed as the envelope sender address. It should go away. It is only used if the UseErrorsTo
option is set.
The Errors-To: header is officially deprecated and will go away in a future release.
2.9.2. Apparently-To:
RFC 822 requires at least one recipient field (To:, Cc:, or Bcc: line) in every message. If a
message comes in with no recipients listed in the message then sendmail will adjust the header
based on the “NoRecipientAction” option. One of the possible actions is to add an “Apparently-
To:” header line for any recipients it is aware of.
The Apparently-To: header is non-standard and is deprecated.
2.9.3. Precedence
The Precedence: header can be used as a crude control of message priority. It tweaks the
sort order in the queue and can be configured to change the message timeout values. The prece-
dence of a message also controls how delivery status notifications (DSNs) are processed for that
message.
Likewise, if the host has been compromised the information returned may be completely erro-
neous and misleading.
The Identification Protocol is not intended as an authorization or access control protocol. At
best, it provides some additional auditing information with respect to TCP connections. At
worst, it can provide misleading, incorrect, or maliciously incorrect information.
The use of the information returned by this protocol for other than auditing is strongly dis-
couraged. Specifically, using Identification Protocol information to make access control deci-
sions - 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 wouldn’t run a "finger" server due to privacy considerations you may
not want to run this protocol.
In some cases your system may not work properly with IDENT support due to a bug in the TCP/IP
implementation. The symptoms will be that for some hosts the SMTP connection will be closed
almost immediately. If this is true or if you do not want to use IDENT, you should set the IDENT
timeout to zero; this will disable the IDENT protocol.
3. ARGUMENTS
The complete list of arguments to sendmail is described in detail in Appendix A. Some important
arguments are described here.
An alternative approach is to invoke sendmail from inetd(8) (use the −bs flag to ask sendmail
to speak SMTP on its standard input and output). This works and allows you to wrap sendmail in a
TCP wrapper program, but may be a bit slower since the configuration file has to be re-read on
every message that comes in. If you do this, you still need to have a sendmail running to flush the
queue:
/usr/sbin/sendmail −q30m
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” lim-
its the run to particular senders and “−qIstring” limits it to particular queue identifiers.
3.4. Debugging
There are a fairly large number of debug flags built into sendmail. Each debug flag has a
number and a level, where higher levels means to print out more information. The convention is
that levels greater than nine are “absurd,” i.e., they print out so much information that you wouldn’t
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 and the TRACE-
FLAGS file in the sendmail distribution (they are too dynamic to keep this document up to date).
Some options have security implications. Sendmail allows you to set these, but relinquishes
its setuid root permissions thereafter12.
while testing.
4. TUNING
There are a number of configuration parameters you may want to change, depending on the
requirements of your site. Most of these are set using an option in the configuration file. For example,
the line “O Timeout.queuereturn=5d” sets option “Timeout.queuereturn” to the value “5d” (five days).
Most of these options have appropriate defaults for 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 experi-
encing 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 prior to 8.7 had single character option names. As of 8.7, options have
long (multi-character names). Although old short names are still accepted, most new options do not
have short equivalents.
This section only describes the options you are most likely to want to tweak; read section 5 for
more details.
4.1. Timeouts
All time intervals are set using a scaled syntax. For example, “10m” represents ten minutes,
whereas “2h30m” represents two and a half hours. The full set of scales is:
s seconds
m minutes
h hours
d days
w weeks
iconnect The same as connect, except it applies only to the initial attempt to connect to
a host for a given message [0, unspecified]. The concept is that this should be
very short (a few seconds); hosts that are well connected and responsive will
thus be serviced immediately. Hosts that are slow will not hold up other deliv-
eries in the initial delivery attempt.
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 host name 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 (see
below).
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 send-
mail which have no guarantee of promptness.
datafinal† The wait for a reply from the dot terminating a message. [1h, 10m]. If this is
shorter than the time actually needed for the receiver to deliver the message,
duplicates will be generated. This is discussed in RFC 1047.
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 [30s13, unspecified].
fileopen‡ The timeout for opening .forward and :include: files [60s, none].
control‡ The timeout for a complete control socket transaction to complete [2m, none].
hoststatus‡ How long status information about a host (e.g., host down) will be cached
before it is considered stale [30m, unspecified].
resolver.retrans The resolver’s retransmission time interval (in seconds) [varies]. Sets both
Timeout.resolver.retrans.first and Timeout.resolver.retrans.normal.
resolver.retrans.first
The resolver’s retransmission time interval (in seconds) for the first attempt to
deliver a message [varies].
resolver.retrans.normal
The resolver’s retransmission time interval (in seconds) for all resolver
lookups except the first delivery attempt [varies].
resolver.retry The number of times to retransmit a resolver query. Sets both Time-
out.resolver.retry.first and Timeout.resolver.retry.normal [varies].
resolver.retry.first The number of times to retransmit a resolver query for the first attempt to
deliver a message [varies].
13
On some systems the default is zero to turn the protocol off entirely.
Sendmail Installation and Operation Guide SMM:08-25
resolver.retry.normal
The number of times to retransmit a resolver query for all resolver lookups
except the first delivery attempt [varies].
For compatibility with old configuration files, if no suboption is specified, all the timeouts
marked with a dagger (†) are set to the indicated value. All but those marked with a double dag-
ger (‡) apply to client SMTP.
Many of the RFC 1123 minimum values may well be too short. Sendmail was designed to
the RFC 822 protocols, which did not specify read timeouts; hence, versions of sendmail prior
to version 8.1 did not guarantee to reply to messages promptly. In particular, a “RCPT” com-
mand specifying a mailing list will expand and verify the entire list; a large list on a slow system
may easily take more than five minutes14. I recommend a one hour timeout — since a commu-
nications failure during the RCPT phase is rare, a long timeout is not onerous and may ulti-
mately help reduce network load and duplicated messages.
For example, the lines:
O Timeout.command=25m
O Timeout.datablock=3h
sets the server SMTP command timeout to 25 minutes and the input data block timeout to three
hours.
14
This verification includes looking up every address with the name server; this involves network delays, and can in some cases
can be considerable.
SMM:08-26 Sendmail Installation and Operation Guide
causes email to fail after five days, but a warning message will be sent after four hours. This
should be large enough that the message will have been tried several times.
in unsafe directories.
DontWarnForwardFileInUnsafeDirPath
Prevent logging of unsafe directory path warnings for non-existent forward files.
ErrorHeaderInUnsafeDirPath
Allow the file named in the ErrorHeader option to be in an unsafe directory.
FileDeliveryToHardLink
Allow delivery to files that are hard links.
FileDeliveryToSymLink
Allow delivery to files that are symbolic links.
ForwardFileInGroupWritableDirPath
Allow .forward files in group writable directories.
ForwardFileInUnsafeDirPath
Allow .forward files in unsafe directories.
ForwardFileInUnsafeDirPathSafe
Allow a .forward file that is in an unsafe directory to include references to program and
files.
GroupWritableAliasFile
Allow group-writable alias files.
GroupWritableDirPathSafe
Change the definition of “unsafe directory” to consider group-writable directories to be
safe. World-writable directories are always unsafe.
GroupWritableForwardFileSafe
Accept group-writable .forward files as safe for program and file delivery.
GroupWritableIncludeFileSafe
Accept group-writable :include: files as safe for program and file delivery.
HelpFileInUnsafeDirPath
Allow the file named in the HelpFile option to be in an unsafe directory.
IncludeFileInGroupWritableDirPath
Allow :include: files in group writable directories.
IncludeFileInUnsafeDirPath
Allow :include: files in unsafe directories.
IncludeFileInUnsafeDirPathSafe
Allow a :include: file that is in an unsafe directory to include references to program
and files.
InsufficientEntropy
Try to use STARTTLS even if the PRNG for OpenSSL is not properly seeded despite
the security problems.
LinkedAliasFileInWritableDir
Allow an alias file that is a link in a writable directory.
LinkedClassFileInWritableDir
Allow class files that are links in writable directories.
LinkedForwardFileInWritableDir
Allow .forward files that are links in writable directories.
LinkedIncludeFileInWritableDir
Allow :include: files that are links in writable directories.
SMM:08-30 Sendmail Installation and Operation Guide
LinkedMapInWritableDir
Allow map files that are links in writable directories.
LinkedServiceSwitchFileInWritableDir
Allow the service switch file to be a link even if the directory is writable.
MapInUnsafeDirPath
Allow maps (e.g., hash, btree, and dbm files) in unsafe directories.
NonRootSafeAddr
Do not mark file and program deliveries as unsafe if sendmail is not running with root
privileges.
RunProgramInUnsafeDirPath
Go ahead and run programs that are in writable directories.
RunWritableProgram
Go ahead and run programs that are group- or world-writable.
TrustStickyBit
Allow group or world writable directories if the sticky bit is set on the directory. Do
not set this on systems which do not honor the sticky bit on directories.
WorldWritableAliasFile
Accept world-writable alias files.
WriteMapToHardLink
Allow writes to maps that are hard links.
WriteMapToSymLink
Allow writes to maps that are symbolic links.
WriteStatsToHardLink
Allow the status file to be a hard link.
WriteStatsToSymLink
Allow the status file to be a symbolic link.
/etc/mail/service.switch, which should be created. Sendmail only uses two entries: hosts and
aliases, although system routines may use other services (notably the passwd service for user name
lookups by getpwname).
However, some systems (such as SunOS 4.X) will do DNS lookups regardless of the setting
of the service switch entry. In particular, the system routine gethostbyname(3) is used to look up
host names, and many vendor versions try some combination of DNS, NIS, and 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 nameserver configured at
all, such as at a UUCP-only site, sendmail will get a “connection refused” message when it tries to
connect to the name server. If the hosts switch entry has the service “dns” listed somewhere in the
list, sendmail will interpret this to mean a temporary failure and will queue the mail for later pro-
cessing; otherwise, it ignores the name server data.
The same technique is used to decide whether to do MX lookups. If you want MX support,
you must have “dns” listed as a service in the hosts switch entry.
The ResolverOptions (I) option allows you to tweak name server options. The command
line takes a series of flags as documented in resolver(3) (with the leading “RES_” deleted). Each
can be preceded by an optional ‘+’ or ‘−’. For example, the line
O ResolverOptions=+AAONLY −DNSRCH
turns on the AAONLY (accept authoritative answers only) and turns off the DNSRCH (search the
domain path) options. Most resolver libraries default DNSRCH, DEFNAMES, and RECURSE
flags on and all others off. You can also include “HasWildcardMX” to specify that there is a wild-
card MX record matching your domain; this turns off MX matching when canonifying names,
which can lead to inappropriate canonifications.
Version level 1 configurations turn DNSRCH and DEFNAMES off when doing delivery
lookups, but leave them on everywhere else. Version 8 of sendmail ignores them when doing
canonification lookups (that is, when using $[ ... $]), and always does the search. If you don’t want
to do automatic name extension, don’t call $[ ... $].
The search rules for $[ ... $] are somewhat different than usual. If the name being looked up
has at least one dot, it always tries the unmodified name first. If that fails, it tries the reduced search
path, and lastly tries the unmodified name (but only for names without a dot, since names with a dot
have already been tried). This allows names such as ‘‘utc.CS’’ to match the site in Czechoslovakia
rather than the site in your local Computer Science department. It also prefers A and CNAME
records over MX records — that is, if it finds an MX record it makes note of it, but keeps looking.
This way, if you have a wildcard MX record matching your domain, it will not assume that all
names match.
To completely turn off all name server access on systems without service switch support
(such as SunOS 4.X) you will have to recompile with −DNAMED_BIND=0 and remove −lresolv
from the list of libraries to be searched when linking.
truly perverse site could also search by sender by using $r, $s, or $f.
If you create a directory such as /var/forward, it should be mode 1777 (that is, the sticky bit
should be set). Users should create the files mode 644. Note that you must use the forwardfileinun-
safedirpath and forwardfileinunsafedirpathsafe flags with the DontBlameSendmail option to allow
forward files in a world writable directory. This might also be used as a denial of service attack
(users could create forward files for other users); a better approach might be to create /var/forward
mode 755 and create empty files for each user, owned by that user, mode 644. If you do this, you
don’t have to set the DontBlameSendmail options indicated above.
The configuration file is organized as a series of lines, each of which begins with a single charac-
ter 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.
Additionally, the LHS can include $@ to match zero tokens. This is not bound to a $n on
the RHS, and is normally only used when it stands alone in order to match the null input.
SMM:08-34 Sendmail Installation and Operation Guide
The $n syntax substitutes the corresponding value from a $+, $−, $*, $=, or $˜ match on
the LHS. It may be used anywhere.
A host name enclosed between $[ and $] is looked up in the host database(s) and replaced
by the canonical name15. For example, “$[ftp$]” might become “ftp.CS.Berkeley.EDU” and
“$[[128.32.130.2]$]” would become “vangogh.CS.Berkeley.EDU.” Sendmail recognizes its
numeric IP address without calling the name server and replaces it with its canonical name.
The $( ... $) syntax is a more general form of lookup; it uses a named map instead of an
implicit map. If no lookup is found, the indicated default is inserted; if no default is specified
and no lookup matches, the value is left unchanged. The arguments are passed to the map for
possible use.
The $>n syntax causes the remainder of the line to be substituted as usual and then passed
as the argument to ruleset n. The final value of ruleset n then becomes the substitution for this
rule. The $> syntax expands everything after the ruleset name to the end of the replacement
string and then passes that as the initial input to the ruleset. Recursive calls are allowed. For
example,
$>0 $>3 $1
expands $1, passes that to ruleset 3, and then passes the result of ruleset 3 to ruleset 0.
The $# syntax should only be used in ruleset zero or a subroutine of ruleset zero. It causes
evaluation of the ruleset to terminate immediately, and signals to sendmail that the address has
completely resolved. The complete syntax is:
$#mailer $@host $:user
This specifies the {mailer, host, user} 3-tuple necessary to direct the mailer. If the mailer is
local the host part may be omitted16. The mailer must be a single word, but the host and user
may be multi-part. If the mailer is the builtin IPC mailer, the host may be a colon-separated list
of hosts that are searched in order for the first working address (exactly like MX records). The
user is later rewritten by the mailer-specific envelope rewriting set and assigned to the $u macro.
As a special case, if the mailer specified has the F=@ flag specified and the first character of the
$: value is “@”, the “@” is stripped off, and a flag is set in the address descriptor that causes
sendmail to not do ruleset 5 processing.
15
This is actually completely equivalent to $(host hostname$). In particular, a $: default can be used.
16
You may want to use it for special “per user” extensions. For example, in the address “[email protected]”; the “+foo”
part is not part of the user name, and is passed to the local mailer for local use.
Sendmail Installation and Operation Guide SMM:08-35
Normally, a rule that matches is retried, that is, the rule loops until it fails. A RHS may
also be preceded by a $@ or a $: to change this behavior. A $@ prefix causes the ruleset to
return with the remainder of the RHS as the value. A $: prefix causes the rule to terminate
immediately, but the ruleset to continue; this can be used to avoid continued application of a
rule. The prefix is stripped before continuing.
The $@ and $: prefixes may precede a $> spec; for example:
R$+ $: $>7 $1
matches anything, passes that to ruleset seven, and continues; the $: is necessary to avoid an
infinite loop.
Substitution occurs in the order described, that is, parameters from the LHS are substi-
tuted, hostnames are canonicalized, “subroutines” are called, and finally $#, $@, and $: are pro-
cessed.
0 resolved address
1 S
addr 3 D 4 msg
2 R
Rulesets one and two are applied to all sender and recipient addresses respectively. They
are applied before any specification in the mailer definition. They must never resolve.
Ruleset four is applied to all addresses in the message. It is typically used to translate
internal to external form.
In addition, ruleset 5 is applied to all local addresses (specifically, those that resolve to a
mailer with the ‘F=5’ flag set) that do not have aliases. This allows a last minute hook for local
names.
5.1.4.1. check_relay
The check_relay ruleset is called after a connection is accepted by the daemon. It is
not called when sendmail is started using the −bs option. It is passed
client.host.name $| client.host.address
where $| is a metacharacter separating the two parts. This ruleset can reject connections
from various locations.
5.1.4.2. check_mail
The check_mail ruleset is passed the user name parameter of the SMTP MAIL com-
mand. It can accept or reject the address.
5.1.4.3. check_rcpt
The check_rcpt ruleset is passed the user name parameter of the SMTP RCPT com-
mand. It can accept or reject the address.
5.1.4.4. check_compat
The check_compat ruleset is passed
sender-address $| recipient-address
where $| is a metacharacter separating the addresses. It can accept or reject mail transfer
between these two addresses much like the checkcompat() function.
5.1.4.5. check_eoh
The check_eoh ruleset is passed
number-of-headers $| size-of-headers
where $| is a metacharacter separating the numbers. These numbers can be used for size
comparisons with the arith map. The ruleset is triggered after all of the headers have been
read. It can be used to correlate information gathered from those headers using the macro
storage map. One possible use is to check for a missing header. For example:
Sendmail Installation and Operation Guide SMM:08-37
Kstorage macro
HMessage-Id: $>CheckMessageId
SCheckMessageId
# Record the presence of the header
R$* $: $(storage {MessageIdCheck} $@ OK $) $1
R< $+ @ $+ > $@ OK
R$* $#error $: 553 Header Error
Scheck_eoh
# Check the macro
R$* $: < $&{MessageIdCheck} >
# Clear the macro for the next message
R$* $: $(storage {MessageIdCheck} $) $1
# Has a Message-Id: header
R< $+ > $@ OK
# Allow missing Message-Id: from local mail
R$* $: < $&{client_name} >
R< > $@ OK
R< $=w > $@ OK
# Otherwise, reject the mail
R$* $#error $: 553 Header Error
Keep in mind the Message-Id: header is not a required header and is not a guaranteed spam
indicator. This ruleset is an example and should probably not be used in production.
5.1.4.6. check_etrn
The check_etrn ruleset is passed the parameter of the SMTP ETRN command. It can
accept or reject the command.
5.1.4.7. check_expn
The check_expn ruleset is passed the user name parameter of the SMTP EXPN com-
mand. It can accept or reject the address.
5.1.4.8. check_vrfy
The check_vrfy ruleset is passed the user name parameter of the SMTP VRFY com-
mand. It can accept or reject the command.
5.1.4.9. trust_auth
The trust_auth ruleset is passed the AUTH= parameter of the SMTP MAIL command.
It is used to determine whether this value should be trusted. In order to make this decision,
the ruleset may make use of the various ${auth_*} macros. If the ruleset does resolve to the
“error” mailer the AUTH= parameter is not trusted and hence not passed on to the next relay.
5.1.4.10. tls_client
The tls_client ruleset is called when sendmail acts as server, after a STARTTLS com-
mand has been issued, and from check_mail. The parameter is the value of ${verify} and
STARTTLS or MAIL, respectively. If the ruleset does resolve to the “error” mailer, the
appropriate error code is returned to the client.
SMM:08-38 Sendmail Installation and Operation Guide
5.1.4.11. tls_server
The tls_server ruleset is called when sendmail acts as client after a STARTTLS com-
mand (should) have been issued. The parameter is the value of ${verify}. If the ruleset does
resolve to the “error” mailer, the connection is aborted (treated as non-deliverable with a per-
manent or temporary error).
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
argv’s for mailers or for other contexts. The ones marked † are information passed into sendmail17,
the ones marked ‡ are information passed both in and out of sendmail, and the unmarked macros are
passed out of sendmail but are not otherwise used internally. These macros are:
$a 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. This is a count of the number of Received: lines plus the value of the −h com-
mand line flag.
$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 “$j Sendmail $v ready at $b”. Commonly redefined to include the con-
figuration version number, e.g., “$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”,
“[email protected]”, or whatever is appropriate for the receiving mailer.
$h The recipient host. This is set in ruleset 0 from the $@ field of a parsed address.
$i The queue id, e.g., “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 con-
figured so that information can find it automatically.
$k The UUCP node name (from the uname system call).
$l† (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 equiv-
alent 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 which will be considered tokens and which will separate tokens when doing pars-
ing. 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 <[email protected]>
[email protected] (Eric Allman)
Sendmail properly quotes names that have special characters if the first form is used.
17
As of version 8.6, all of these macros have reasonable defaults. Previous versions required that they be defined.
SMM:08-40 Sendmail Installation and Operation Guide
$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 hostname of this site. This 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.
${auth_authen}
The client’s authentication credentials as determined by authentication (only set if success-
ful).
${auth_author}
The authorization identity, i.e. the AUTH= parameter of the SMTP MAIL command if sup-
plied.
${auth_type}
The mechanism used for authentication (only set if successful).
${auth_ssf}
The keylength (in bits) of the symmetric encryption algorithm used for the security layer of a
SASL mechanism.
${bodytype}
The message body type (7BIT or 8BITMIME), as determined from the envelope.
${cert_issuer}
The DN (distinguished name) of the CA (certificate authority) that signed the presented cer-
tificate (the cert issuer).
${cert_subject}
The DN of the presented certificate (called the cert subject).
${cipher}
The cipher suite used for the connection, e.g., EDH-DSS-DES-CBC3-SHA, EDH-RSA-DES-
CBC-SHA, DES-CBC-MD5, DES-CBC3-SHA.
${cipher_bits}
The keylength (in bits) of the symmetric encryption algorithm used for a TLS connection.
${client_addr}
The IP address of the SMTP client. Defined in the SMTP server only.
${client_name}
The host name of the SMTP client. This may be the client’s bracketed IP address in the form
[ nnn.nnn.nnn.nnn ] if the client’s IP address is not resolvable, or if it is resolvable but the IP
address of the resolved hostname doesn’t match the original IP address. Defined in the SMTP
server only.
${client_port}
The port number of the SMTP client. Defined in the SMTP server only.
${client_resolve}
Holds the result of the resolve call for ${client_name} : OK, FAIL, FORGED, TEMP.
Defined in the SMTP server only.
Sendmail Installation and Operation Guide SMM:08-41
${currHeader}
Header value as quoted string (possibly truncated to MAXNAME).
${daemon_addr}
The IP address the daemon is listening on for connections. Unless DaemonPortOptions is
set, this will be “0.0.0.0”.
${daemon_family}
The network family if the daemon is accepting network connections. Possible values include
“inet”, “inet6”, “iso”, “ns”, “x.25”
${daemon_flags}
The flags for the daemon as specified by the Modifier= part of DaemonPortOptions whereby
the flags are separated from each other by spaces, and upper case flags are doubled. That is,
Modifier=Ea will be represented as "EE a" in ${daemon_flags}, which is required for testing
the flags in rulesets.
${daemon_info}
Some information about a daemon as a text string. For example, “SMTP+queue-
ing@00:30:00”.
${daemon_name}
The name of the daemon from DaemonPortOptions Name= suboption. If this suboption is
not set, "Daemon#", where # is the daemon number, is used.
${daemon_port}
The port the daemon is accepting connection on. Unless DaemonPortOptions is set, this
will most likely be “25”.
${deliveryMode}
The current delivery mode sendmail is using. It is initially set to the value of the Delivery-
Mode option.
${envid}
The envelope id passed to sendmail as part of the envelope.
${hdrlen}
The length of the header value which is stored in ${currHeader} (before possible truncation).
If this value is greater than or equal MAXNAME the header has been truncated.
${hdr_name}
The name of the header field for which the current header check ruleset has been called. This
is useful for a default header check ruleset to get the name of the header.
${if_addr}
The IP address of the interface of an incoming connection unless it is in the loopback net.
${if_family}
The IP family of the interface of an incoming connection unless it is in the loopback net.
${if_name}
The name of the interface of an incoming connection. This macro can be used for Smtp-
GreetingMessage and HReceived for virtual hosting. For example:
O SmtpGreetingMessage=$?{if_name}${if_name}$|$j$. MTA
${mail_addr}
The address part of the resolved triple of the address given for the SMTP MAIL command.
Defined in the SMTP server only.
${mail_host}
The host from the resolved triple of the address given for the SMTP MAIL command. Defined
in the SMTP server only.
SMM:08-42 Sendmail Installation and Operation Guide
${mail_mailer}
The mailer from the resolved triple of the address given for the SMTP MAIL command.
Defined in the SMTP server only.
${msg_size}
The value of the SIZE= parameter, i.e., usually the size of the message (in an ESMTP dia-
logue), before the message has been collected, thereafter the message size as computed by
sendmail (and can be used in check_compat).
${ntries}
The number of delivery attempts.
${opMode}
The current operation mode (from the −b flag).
${queue_interval}
The queue run interval given by the −q flag. For example, −q30m would set ${queue_inter-
val} to “00:30:00”.
${rcpt_addr}
The address part of the resolved triple of the address given for the SMTP RCPT command.
Defined in the SMTP server only.
${rcpt_host}
The host from the resolved triple of the address given for the SMTP RCPT command. Defined
in the SMTP server only.
${rcpt_mailer}
The mailer from the resolved triple of the address given for the SMTP RCPT command.
Defined in the SMTP server only.
${server_addr}
The address of the server of the current outgoing SMTP connection.
${server_name}
The name of the server of the current outgoing SMTP connection.
${tls_version}
The TLS/SSL version used for the connection, e.g., TLSv1, SSLv3, SSLv2.
${verify}
The result of the verification of the presented cert. Possible values are:
OK verification succeeded.
NO no cert presented.
FAIL cert presented but could not be verified,
e.g., the signing CA is missing.
NONE STARTTLS has not been performed.
TEMP temporary error occurred.
PROTOCOL some protocol error occurred.
SOFTWARE STARTTLS handshake failed,
which is a fatal error for this session,
the e-mail will be queued.
There are three types of dates that can be used. The $a and $b macros are in RFC 822 for-
mat; $a is the time as extracted from the “Date:” line of the message (if there was one), and $b is
the current date and time (used for postmarks). If no “Date:” line is found in the incoming message,
$a is set to the current time also. The $d macro is equivalent to the $b macro in UNIX (ctime) for-
mat.
The macros $w, $j, and $m are set to the identity of this host. Sendmail tries to find the fully
qualified name of the host if at all possible; it does this by calling gethostname(2) to get the current
Sendmail Installation and Operation Guide SMM:08-43
hostname and then passing that to gethostbyname(3) which is supposed to return the canonical ver-
sion of that host name.18 Assuming this is successful, $j is set to the fully qualified name and $m is
set to the domain part of the name (everything after the first dot). The $w macro is set to the first
word (everything before the first dot) if you have a level 5 or higher configuration file; otherwise, it
is set to the same value as $j. If the canonification is not successful, it is imperative that the config
file set $j to the fully qualified domain name19.
The $f macro is the id of the sender as originally determined; when mailing to a specific host
the $g macro is set to the address of the sender relative to the recipient. For example, if I send to
“[email protected]” from the machine “vangogh.CS.Berkeley.EDU” the $f macro
will be “eric” and the $g macro will be “[email protected].”
The $x macro is set to the full name of the sender. This can be determined in several ways. It
can be passed as flag to sendmail. It can be defined in the NAME environment variable. The third
choice is the value of the “Full-Name:” line in the header if it exists, and the fourth choice is the
comment field of a “From:” line. If all of these fail, and if the message is being originated locally,
the full name is looked up in the /etc/passwd file.
When sending, the $h, $u, and $z macros get set to the host, user, and home directory (if
local) of the recipient. The first two are set from the $@ and $: part of the rewriting rules, respec-
tively.
The $p and $t macros are used to create unique strings (e.g., for the “Message-Id:” field).
The $i macro is set to the queue id on this host; if put into the timestamp line it can be extremely
useful for tracking messages. The $v macro is set to be the version number of sendmail; this is nor-
mally put in timestamps and has been proven extremely useful for debugging.
The $c field is set to the “hop count,” i.e., the number of times this message has been pro-
cessed. 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 send-
ing hostname. They can be set together using the −p command line flag or separately using the −M
or −oM flags.
The $_ is set to a validated sender host name. If the sender is running an RFC 1413 compli-
ant IDENT server and the receiver has the IDENT protocol turned on, it will include the user name
on that host.
The ${client_name}, ${client_addr}, and ${client_port} macros are set to the name,
address, and port number of the SMTP client who is invoking sendmail as a server. These can be
used in the check_* rulesets (using the $& deferred evaluation form, of course!).
18
For example, on some systems gethostname might return “foo” which would be mapped to “foo.bar.com” by gethostbyname.
19
Older versions of sendmail didn’t pre-define $j at all, so up until 8.6, config files always had to define $j.
SMM:08-44 Sendmail Installation and Operation Guide
d Do not include angle brackets around route-address syntax addresses. This is useful on mailers
that are going to pass addresses to a shell that might interpret angle brackets as I/O redirection.
However, it does not protect against other shell metacharacters. Therefore, passing addresses
to a shell should not be considered secure.
D† This mailer wants a “Date:” header line.
e This mailer is expensive to connect to, so try to avoid connecting normally; any necessary con-
nection will occur during a queue run. See also option HoldExpensive.
E Escape lines beginning with “From ” in the message with a ‘>’ sign.
f The mailer wants a −f from flag, but only if this is a network forward operation (i.e., the mailer
will give an error if the executing user does not have special permissions).
F† This mailer wants a “From:” header line.
g Normally, sendmail sends internally generated email (e.g., error messages) using the null
return address as required by RFC 1123. However, some mailers don’t 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 Upper case should be preserved in host names (the $@ portion of the mailer triplet resolved
from ruleset 0) for this mailer.
i Do User Database rewriting on envelope sender address.
I This mailer will be speaking SMTP to another sendmail — as such it can use special protocol
features. This option is not required (i.e., if this option is omitted the transmission will still
operate successfully, although perhaps not as efficiently as possible).
j Do User Database rewriting on recipients as well as senders.
k Normally when sendmail connects to a host via SMTP, it checks to make sure that this isn’t
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 unusual circumstances.
K Currently unimplemented. Reserved for chunking.
l This mailer is local (i.e., 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. Removing this flag can defeat duplicate supression on a remote site as each
recipient is sent in a separate transaction.
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 deliv-
ering 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.
Sendmail Installation and Operation Guide SMM:08-47
Configuration files prior to level 6 assume the ‘A’, ‘w’, ‘5’, ‘:’, ‘|’, ‘/’, and ‘@’ options on the
mailer named “local”.
The mailer with the special name “error” can be used to generate a user error. The (optional)
host field is an exit status to be returned, and the user field is a message to be printed. The exit sta-
tus may be numeric or one of the values USAGE, NOUSER, NOHOST, UNAVAILABLE, SOFT-
WARE, TEMPFAIL, PROTOCOL, or CONFIG to return the corresponding EX_ exit code, or an
enhanced error code as described in RFC 1893, Enhanced Mail System Status Codes. For example,
the entry:
$#error $@ NOHOST $: Host unknown in this domain
on the RHS of a rule will cause the specified error to be generated and the “Host unknown” exit sta-
tus to be returned if the LHS matches. This mailer is only functional in rulesets 0, 5, or one of the
check_* rulesets.
The mailer with the special name “discard” causes any mail sent to it to be discarded but oth-
erwise treated as though it were successfully delivered. This mailer can not be used in ruleset 0,
only in the various address checking rulesets.
The mailer named “local” must be defined in every configuration file. This is used to deliver
local mail, and is treated specially in several ways. Additionally, three other mailers named “prog”,
“*file*”, and “*include*” may be defined to tune the delivery of messages to programs, files, and
:include: lists respectively. They default to:
Mprog, P=/bin/sh, F=lsoDq9, T=DNS/RFC822/X-Unix, A=sh −c $u
M*file*, P=[FILE], F=lsDFMPEouq9, T=DNS/RFC822/X-Unix, A=FILE $u
M*include*, P=/dev/null, F=su, A=INCLUDE $u
The Sender and Recipient rewriting sets may either be a simple ruleset id or may be two ids
separated by a slash; if so, the first rewriting set is applied to envelope addresses and the second is
applied to headers. Setting any value zero disables corresponding mailer-specific rewriting.
The Directory is actually a colon-separated path of directories to try. For example, the defini-
tion “D=$z:/” first tries to execute in the recipient’s home directory; if that is not available, it tries to
execute in the root of the filesystem. This is intended to be used only on the “prog” mailer, since
some shells (such as csh) refuse to execute if they cannot read the home directory. Since the queue
directory is not normally readable by unprivileged users csh scripts as recipients can fail.
The Userid specifies the default user and group id to run as, overriding the DefaultUser
option (q.v.). If the S mailer flag is also specified, this user and group will be set as the effective uid
and gid for the process. This may be given as user:group to set both the user and group id; either
may be an integer or a symbolic name to be looked up in the passwd and group files respectively. If
only a symbolic user name is specified, the group id in the passwd file for that user is used as the
group id.
The Charset field is used when converting a message to MIME; this is the character set used
in the Content-Type: header. If this is not set, the DefaultCharset option is used, and if that is not
set, the value “unknown-8bit” is used. WARNING: this field applies to the sender’s mailer, not the
recipient’s mailer. For example, if the envelope sender address lists an address on the local network
and the recipient is on an external network, the character set will be set from the Charset= field for
the local network mailer, not that of the external network mailer.
The Type= field sets the type information used in MIME error messages as defined by RFC
1894. It is actually three values separated by slashes: the MTA-type (that is, the description of how
hosts are named), the address type (the description of e-mail addresses), and the diagnostic type (the
description of error diagnostic codes). Each of these must be a registered value or begin with “X−”.
The default is “dns/rfc822/smtp”.
Sendmail Installation and Operation Guide SMM:08-49
The m= field specifies the maximum number of messages to attempt to deliver on a single
SMTP or LMTP connection.
The /= field specifies a new root directory for the mailer. The path is macro expanded and
then passed to the “chroot” system call. The root directory is changed before the Directory field is
consulted or the uid is changed.
The Wait= field specifies the maximum time to wait for the mailer to return after sending all
data to it. This applies to mailers that have been forked by sendmail.
H[?mflags?]hname: htemplate
H[?${macro}?]hname: htemplate
Continuation lines in this spec are reflected directly into the outgoing message. The htemplate is
macro-expanded before insertion into the message. If the mflags (surrounded by question marks)
are specified, at least one of the specified flags must be stated in the mailer definition for this header
to be automatically output. If a ${macro} (surrounded by question marks) is specified, the header
will be automatically output if the macro is set. The macro may be set using any of the normal
methods, including using the macro storage map in a ruleset. If one of these headers is in the input
it is reflected to the output regardless of these flags or macros.
Some headers have special semantics that will be described later.
A secondary syntax allows validation of headers as they are being read. To enable validation,
use:
HHeader: $>Ruleset
HHeader: $>+Ruleset
The indicated Ruleset is called for the specified Header, and can return $#error to reject the mes-
sage or $#discard to discard the message (as with the other check_* rulesets). The ruleset receives
the header field-body as argument, i.e., not the header field-name; see also ${hdr_name} and ${cur-
rHeader}. The header is treated as a structured field, that is, comments (in parentheses) are deleted
before processing, unless the second form $>+ is used. Note: only one ruleset can be associated
with a header; sendmail will silently ignore multiple entries.
For example, the configuration lines:
HMessage-Id: $>CheckMessageId
SCheckMessageId
R< $+ @ $+ > $@ OK
R$* $#error $: Illegal Message-Id header
would refuse any message that had a Message-Id: header of any of the following forms:
Message-Id: <>
Message-Id: some text
Message-Id: <legal text@domain> extra crud
A default ruleset that is called for headers which don’t have a specific ruleset defined for them can
be specified by:
H*: $>Ruleset
or
SMM:08-50 Sendmail Installation and Operation Guide
H*: $>+Ruleset
BlankSub=c [B] Set the blank substitution character to c. Unquoted spaces in addresses are
replaced by this character. Defaults to space (i.e., no change is made).
CACERTPath [no short name] Path to directory with certificates of CAs.
CACERTFile [no short name] File containing one CA certificate.
CheckAliases [n] Validate the RHS of aliases when rebuilding the alias database.
CheckpointInterval=N
[C] Checkpoints the queue every N (default 10) addresses sent. If your system
crashes during delivery to a large list, this prevents retransmission to any but the
last N recipients.
ClassFactor=fact [z] The indicated factor is multiplied by the message class (determined by the
Precedence: field in the user header and the P lines in the configuration file) and
subtracted from the priority. Thus, messages with a higher Priority: will be
favored. Defaults to 1800.
ClientCertFile [no short name] File containing the certificate of the client, i.e., this certificate is
used when sendmail acts as client.
ClientPortOptions=options
[O] Set client SMTP options. The options are key=value pairs separated by com-
mas. Known keys are:
Port Name/number of source port for connection (defaults to any free port)
Addr Address mask (defaults INADDR_ANY)
Family Address family (defaults to INET)
SndBufSize Size of TCP send buffer
RcvBufSize Size of TCP receive buffer
Modifier Options (flags) for the daemon
The Address mask may be a numeric address in dot notation or a network name.
Modifier can be the following character:
h use name of interface for HELO command
If ‘‘h’’ is set, the name corresponding to the outgoing interface address (whether
chosen via the Connection parameter or the default) is used for the HELO/EHLO
command.
ClientKeyFile [no short name] File containing the private key belonging to the client certificate.
ColonOkInAddr [no short name] If set, colons are acceptable in e-mail addresses (e.g.,
“host:user”). If not set, colons indicate the beginning of a RFC 822 group con-
struct (“groupname: member1, member2, ... memberN;”). Doubled colons are
always acceptable (“nodename::user”) and proper route-addr nesting is under-
stood (“<@relay:user@host>”). Furthermore, this option defaults on if the con-
figuration version level is less than 6 (for back compatibility). However, it must
be off for full compatibility with RFC 822.
ConnectionCacheSize=N
[k] The maximum number of open connections that will be cached at a time. The
default is one. This delays closing the current connection until either this invoca-
tion of sendmail needs to connect to another host or it terminates. Setting it to
zero defaults to the old behavior, that is, connections are closed immediately.
Since this consumes file descriptors, the connection cache should be kept small: 4
is probably a practical maximum.
ConnectionCacheTimeout=timeout
[K] The maximum amount of time a cached connection will be permitted to idle
without activity. If this time is exceeded, the connection is immediately closed.
SMM:08-52 Sendmail Installation and Operation Guide
This value should be small (on the order of ten minutes). Before sendmail uses a
cached connection, it always sends a RSET command to check the connection; if
this fails, it reopens the connection. This keeps your end from failing if the other
end times out. The point of this option is to be a good network neighbor and
avoid using up excessive resources on the other end. The default is five minutes.
ConnectOnlyTo=address
[no short name] This can be used to override the connection address (for testing
purposes).
ConnectionRateThrottle=N
[no short name] If set to a positive value, allow no more than N incoming daemon
connections in a one second period. This is intended to flatten out peaks and
allow the load average checking to cut in. Defaults to zero (no limits).
ControlSocketName=name
[no short name] Name of the control socket for daemon management. A running
sendmail daemon can be controlled through this named socket. Available com-
mands are: help, restart, shutdown, and status. The status command returns the
current number of daemon children, the maximum number of daemon children,
the free disk space (in blocks) of the queue directory, and the load average of the
machine expressed as an integer. If not set, no control socket will be available.
Solaris and pre-4.4BSD kernel users should see the note in sendmail/README .
DHParameters File with DH parameters for STARTTLS. This is only required if DSA/DH is
used.
DaemonPortOptions=options
[O] Set server SMTP options. Each instance of DaemonPortOptions leads to an
additional incoming socket. The options are key=value pairs. Known keys are:
Name User-definable name for the daemon (defaults to "Daemon#")
Port Name/number of listening port (defaults to "smtp")
Addr Address mask (defaults INADDR_ANY)
Family Address family (defaults to INET)
Listen Size of listen queue (defaults to 10)
Modifier Options (flags) for the daemon
SndBufSize Size of TCP send buffer
RcvBufSize Size of TCP receive buffer
The Name field is used for error messages and logging. The Address mask may
be a numeric address in dot notation or a network name. The Family key defaults
to INET (IPv4). IPv6 users who wish to also accept IPv6 connections should add
additional Family=inet6 DaemonPortOptions lines. Modifier can be a sequence
(without any delimiters) of the following characters:
a always require authentication
b bind to interface through which mail has been received
c perform hostname canonification (.cf)
f require fully qualified hostname (.cf)
u allow unqualified addresses (.cf)
C don’t perform hostname canonification
E disallow ETRN (see RFC 2476)
That is, one way to specify a message submission agent (MSA) that always
requires authentication is:
O DaemonPortOptions=Name=MSA, Port=587, M=Ea
The modifiers that are marked with "(.cf)" have only effect in the standard
Sendmail Installation and Operation Guide SMM:08-53
configuration file, in which they are available via ${daemon_flags}. The flags
‘‘c’’ and ‘‘C’’ can change the default for hostname canonification in the send-
mail.cf file. See the relevant documentation for FEATURE(nocanonify). The modi-
fier ‘‘f ’’ disallows addresses of the form user@host unless they are submitted
directly. The flag ‘‘u’’ allows unqualified sender addresses. ‘‘b’’ forces sendmail
to bind to the interface through which the e-mail has been received for the outgo-
ing connection. WARNING: Use ‘‘b’’ only if outgoing mail can be routed
through the incoming connection’s interface to its destination. No attempt is made
to catch problems due to a misconfiguration of this parameter, use it only for vir-
tual hosting where each virtual interface can connect to every possible location.
This will also override possible settings via ClientPortOptions. Note, sendmail
will listen on a new socket for each occurence of the DaemonPortOptions option
in a configuration file.
DefaultAuthInfo [no short name] Filename that contains default authentication information for out-
going connections. This file must contain the user id, the authorization id, the
password (plain text), and the realm to use on separate lines and must be readable
by root (or the trusted user) only. If no realm is specified, $j is used.
DefaultCharSet=charset
[no short name] When a message that has 8-bit characters but is not in MIME for-
mat 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.
DataFileBufferSize=threshold
[no short name] Set the threshold, in bytes, before a memory-based queue data file
becomes disk-based. The default is 4096 bytes.
DeadLetterDrop=file
[no short name] Defines the location of the system-wide dead.letter file, formerly
hardcoded to /usr/tmp/dead.letter. If this option is not set (the default), sendmail
will not attempt to save to a system-wide dead.letter file in the event it can not
bounce the mail to the user or postmaster. Instead, it will rename the qf file as it
has in the past when the dead.letter file could not be opened.
DefaultUser=user:group
[u] Set the default userid for mailers to user:group. If group is omitted and user is
a user name (as opposed to a numeric user id) the default group listed in the
/etc/passwd file for that user is used as the default group. Both user and group
may be numeric. Mailers without the S flag in the mailer definition will run as
this user. Defaults to 1:1. The value can also be given as a symbolic user name.20
DeliveryMode=x [d] Deliver in mode x. Legal modes are:
i Deliver interactively (synchronously)
b Deliver in background (asynchronously)
q Just queue the message (deliver during queue run)
d Defer delivery and all map lookups (deliver during queue run)
Defaults to ‘‘b’’ if no option is specified, ‘‘i’’ if it is specified but given no argu-
ment (i.e., ‘‘Od’’ is equivalent to ‘‘Odi’’). The −v command line flag sets this to i.
20
The old g option has been combined into the DefaultUser option.
SMM:08-54 Sendmail Installation and Operation Guide
DialDelay=sleeptime
[no short name] Dial-on-demand network connections can see timeouts if a con-
nection is opened before the call is set up. If this is set to an interval and a con-
nection 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, so “DialDe-
lay=5” uses a five second delay. Defaults to zero (no retry).
DontBlameSendmail=option,option,...
[no short name] In order to avoid possible cracking attempts caused by world- and
group-writable files and directories, sendmail does paranoid checking when open-
ing most of its support files. If for some reason you absolutely must run with, for
example, a group-writable /etc directory, then you will have to turn off this check-
ing (at the cost of making your system more vulnerable to attack). The arguments
are individual options that turn off checking:
Safe
AssumeSafeChown
ClassFileInUnsafeDirPath
DontWarnForwardFileInUnsafeDirPath
ErrorHeaderInUnsafeDirPath
FileDeliveryToHardLink
FileDeliveryToSymLink
ForwardFileInUnsafeDirPath
ForwardFileInUnsafeDirPathSafe
ForwardFileIngroupWritableDirPath
GroupWritableAliasFile
GroupWritableDirPathSafe
GroupWritableForwardFileSafe
GroupWritableIncludeFileSafe
HelpFileinUnsafeDirPath
IncludeFileInUnsafeDirPath
IncludeFileInUnsafeDirPathSafe
IncludeFileIngroupWritableDirPath
InsufficientEntropy
LinkedAliasFileInWritableDir
LinkedClassFileInWritableDir
LinkedForwardFileInWritableDir
LinkedIncludeFileInWritableDir
LinkedMapInWritableDir
LinkedServiceSwitchFileInWritableDir
MapInUnsafeDirPath
NonRootSafeAddr
RunProgramInUnsafeDirPath
RunWritableProgram
TrustStickyBit
WorldWritableAliasFile
WriteMapToHardLink
WriteMapToSymLink
WriteStatsToHardLink
WriteStatsToSymLink
Safe is the default. The details of these flags are described above. Use of this
option is not recommended.
Sendmail Installation and Operation Guide SMM:08-55
DontExpandCnames
[no short name] The standards say that all host addresses used in a mail message
must be fully canonical. For example, if your host is named “Cruft.Foo.ORG”
and also has an alias of “FTP.Foo.ORG”, the former name must be used at all
times. This is enforced during host name 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 restric-
tive. Has no effect on systems that don’t have group lists.
DontProbeInterfaces
[no short name] Sendmail normally finds the names of all interfaces active on
your machine when it starts up and adds their name to the $=w class of known
host aliases. If you have a large number of virtual interfaces or if your DNS
inverse lookups are slow this can be time consuming. This option turns off that
probing. However, you will need to be certain to include all variant names in the
$=w class by some other mechanism.
DontPruneRoutes [R] Normally, sendmail tries to eliminate any unnecessary explicit routes when
sending an error message (as discussed in RFC 1123 § 5.2.6). For example, when
sending an error message to
<@known1,@known2,@known3:user@unknown>
sendmail will strip off the “@known1,@known2” in order to make the route as
direct as possible. However, if the R option is set, this will be disabled, and the
mail will be sent to the first address in the route, even if later addresses are known.
This may be useful if you are caught behind a firewall.
DoubleBounceAddress=error-address
[no short name] If an error occurs when sending an error message, send the error
report (termed a “double bounce” because it is an error “bounce” that occurs
when trying to send another error “bounce”) to the indicated address. The address
is macro expanded at the time of delivery. If not set, defaults to “postmaster”.
EightBitMode=action
[8] Set handling of eight-bit data. There are two kinds of eight-bit data: that
declared as such using the BODY=8BITMIME ESMTP declaration or the
−B8BITMIME command line flag, and undeclared 8-bit data, that is, input that
just happens to be eight bits. There are three basic operations that can happen:
undeclared 8-bit data can be automatically converted to 8BITMIME, undeclared
8-bit data can be passed as-is without conversion to MIME (‘‘just send 8’’), and
declared 8-bit data can be converted to 7-bits for transmission to a non-8BIT-
MIME mailer. The possible actions are:
s Reject undeclared 8-bit data (‘‘strict’’)
m Convert undeclared 8-bit data to MIME (‘‘mime’’)
p Pass undeclared 8-bit data (‘‘pass’’)
In all cases properly declared 8BITMIME data will be converted to 7BIT as
needed.
SMM:08-56 Sendmail Installation and Operation Guide
ErrorHeader=file-or-message
[E] Prepend error messages with the indicated message. If it begins with a slash,
it is assumed to be the pathname of a file containing a message (this is the recom-
mended setting). Otherwise, it is a literal message. The error file might contain
the name, email address, and/or phone number of a local postmaster who could
provide assistance to end users. If the option is missing or null, or if it names a
file which does not exist or which is not readable, no message is printed.
ErrorMode=x [e] Dispose of errors using mode x. The values for x are:
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 stat always
FallbackMXhost=fallbackhost
[V] If specified, the fallbackhost acts like a very low priority MX on every host.
This is intended to be used by sites with poor network connectivity. Messages
which are undeliverable due to temporary address failures (e.g., DNS failure) also
go to the FallBackMX host.
ForkEachJob [Y] If set, deliver each job that is run from the queue in a separate process. Use
this option if you are short of memory, since the default tends to consume consid-
erable amounts of memory while the queue is being processed.
ForwardPath=path
[J] Set the path for searching for users’ .forward files. The default is “$z/.for-
ward”. Some sites that use the automounter may prefer to change this to
“/var/forward/$u” to search a file with the same name as the user in a system
directory. It can also be set to a sequence of paths separated by colons; sendmail
stops at the first file it can successfully and safely open. For example, “/var/for-
ward/$u:$z/.forward” will search first in /var/forward/username and then in ˜user-
name/.forward (but only if the first file does not exist).
HelpFile=file [H] Specify the help file for SMTP. If no file name is specified, "helpfile" is used.
HoldExpensive [c] If an outgoing mailer is marked as being expensive, don’t connect immedi-
ately. This requires that queueing be compiled in, since it will depend on a queue
run process to actually send the mail.
HostsFile=path [no short name] The path to the hosts database, normally “/etc/hosts”. This option
is only consulted when sendmail is canonifying addresses, and then only when
“files” is in the “hosts” service switch entry. In particular, this file is never used
when looking up host addresses; that is under the control of the system gethostby-
name(3) routine.
HostStatusDirectory=path
[no short name] The location of the long term host status information. When set,
information about the status of hosts (e.g., host down or not accepting connec-
tions) will be shared between all sendmail processes; normally, this information is
only held within a single queue run. This option requires a connection cache of at
least 1 to function. If the option begins with a leading ‘/’, it is an absolute path-
name; otherwise, it is relative to the mail queue directory. A suggested value for
sites desiring persistent host status is “.hoststat” (i.e., a subdirectory of the queue
directory).
IgnoreDots [i] Ignore dots in incoming messages. This is always disabled (that is, dots are
always accepted) when reading SMTP mail.
Sendmail Installation and Operation Guide SMM:08-57
LDAPDefaultSpec=spec
[no short name] Sets a default map specification for LDAP maps. The value
should only contain LDAP specific settings such as “-h host -p port -d bindDN”.
The settings will be used for all LDAP maps unless the individual map specifica-
tion overrides a setting. This option should be set before any LDAP maps are
defined.
LogLevel=n [L] Set the log level to n. Defaults to 9.
Mx value [no long version] Set the macro x to value. This is intended only for use from the
command line. The −M flag is preferred.
MatchGECOS [G] Allow fuzzy matching on the GECOS field. If this flag is set, and the usual
user name lookups fail (that is, there is no alias with this name and a getpwnam
fails), sequentially search the password file for a matching entry in the GECOS
field. This also requires that MATCHGECOS be turned on during compilation.
This option is not recommended.
MaxAliasRecursion=N
[no short name] The maximum depth of alias recursion (default: 10).
MaxDaemonChildren=N
[no short name] If set, sendmail will refuse connections when it has more than N
children processing incoming mail or automatic queue runs. This does not limit
the number of outgoing connections. If not set, there is no limit to the number of
children -- that is, the system load averaging controls this.
MaxHeadersLength=N
[no short name] The maximum length of the sum of all headers. This can be used
to prevent a denial of service attack. The default is no limit.
MaxHopCount=N
[h] The maximum hop count. Messages that have been processed more than N
times are assumed to be in a loop and are rejected. Defaults to 25.
MaxMessageSize=N
[no short name] Specify the maximum message size to be advertised in the
ESMTP EHLO response. Messages larger than this will be rejected.
MaxMimeHeaderLength=N[/M]
[no short name] Sets the maximum length of certain MIME header field values to
N characters. For some of these headers which take parameters, the maximum
length of each parameter is set to M if specified. If /M is not specified, one half of
N will be used. By default, these values are 0, meaning no checks are done.
MaxQueueRunSize=N
[no short name] The maximum number of jobs that will be processed in a single
queue run. If not set, there is no limit on the size. If you have very large queues
or a very short queue run interval this could be unstable. However, since the first
N jobs in queue directory order are run (rather than the N highest priority jobs)
this should be set as high as possible to avoid “losing” jobs that happen to fall late
in the queue directory.
MaxRecipientsPerMessage=N
[no short name] The maximum number of recipients that will be accepted per
message in an SMTP transaction. Note: setting this too low can interfere with
sending mail from MUAs that use SMTP for initial submission. If not set, there is
no limit on the number of recipients per envelope.
MeToo [m] Send to me too, even if I am in an alias expansion. This option is deprecated
and will be removed from a future version.
SMM:08-58 Sendmail Installation and Operation Guide
MinFreeBlocks=N
[b] Insist on at least N blocks free on the filesystem that holds the queue files
before accepting email via SMTP. If there is insufficient space sendmail gives a
452 response to the MAIL command. This invites the sender to try again later.
MinQueueAge=age
[no short name] Don’t process any queued jobs that have been in the queue less
than the indicated time interval. This is intended to allow you to get respon-
siveness by processing the queue fairly frequently without thrashing your system
by trying jobs too often. The default units are minutes.
MustQuoteChars=s
[no short name] Sets the list of characters that must be quoted if used in a full
name that is in the phrase part of a ‘‘phrase <address>’’ syntax. The default is
‘‘´.’’. The characters ‘‘@,;:\()[]’’ are always added to this list.
NoRecipientAction
[no short name] The action to take when you receive a message that has no valid
recipient headers (To:, Cc:, Bcc:, or Apparently-To: — the last included for back
compatibility with old sendmails). It can be None to pass the message on unmod-
ified, 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-Appar-
ently-To to add an Apparently-To: header (this is only for back-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, i.e., spaces delimit names.
This actually turns on an adaptive algorithm: if any recipient address contains a
comma, parenthesis, or angle bracket, it will be assumed that commas already
exist. If this flag is not on, only commas delimit names. Headers are always out-
put 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 sep-
arate tokens but are not tokens themselves — for example, “AAA.BBB” has three
tokens, but “AAA BBB” has two. If not set, OperatorChars defaults to “. : @ [ ]”;
additionally, the characters “( ) < > , ;” are always operators. Note that Operator-
Chars must be set in the configuration file before any rulesets.
PidFile=filename [no short name] Filename of the pid file. (default is _PATH_SENDMAILPID).
The filename is macro-expanded before it is opened.
PostmasterCopy=postmaster
[P] If set, copies of error messages will be sent to the named postmaster. Only the
header of the failed message is sent. Errors resulting from messages with a neg-
ative precedence will not be sent. Since most errors are user problems, this is
probably not a good idea on large sites, and arguably contains all sorts of privacy
violations, but it seems to be popular with certain operating systems vendors. The
address is macro expanded at the time of delivery. Defaults to no postmaster
copies.
PrivacyOptions= opt,opt,...
[p] Set the privacy options. ‘‘Privacy’’ is really a misnomer; many of these are
just a way of insisting on stricter adherence to the SMTP protocol. The options
can be selected from:
Sendmail Installation and Operation Guide SMM:08-59
21
N.B.: the noreceipts flag turns off support for RFC 1891 (Delivery Status Notification).
SMM:08-60 Sendmail Installation and Operation Guide
queued items before starting the queue run. Time ordering is almost always a bad
idea, since it allows large, bulk mail to go out before smaller, personal mail, but
may have applicability on some hosts with very fast connections. Priority order-
ing is the default.
QueueTimeout=timeout
[T] A synonym for “Timeout.queuereturn”. Use that form instead of the “Queue-
Timeout” form.
RandFile [no short name] Name of file containing random data or the name of the UNIX
socket if EGD is used. A (required) prefix "egd:" or "file:" specifies the type.
STARTTLS requires this filename if the compile flag HASURANDOMDEV is
not set (see sendmail/README).
ResolverOptions=options
[I] Set resolver options. Values can be set using +flag and cleared using −flag; the
flags can be “debug”, “aaonly”, “usevc”, “primary”, “igntc”, “recurse”, “def-
names”, “stayopen”, or “dnsrch”. The string “HasWildcardMX” (without a + or
−) can be specified to turn off matching against MX records when doing name
canonifications. N.B. Prior to 8.7, this option indicated that the name server be
responding in order to accept addresses. This has been replaced by checking to
see if the “dns” method is listed in the service switch entry for the “hosts” service.
RrtImpliesDsn [R] If this option is set, a “Return-Receipt-To:” header causes the request of a
DSN, which is sent to the envelope sender as required by RFC1891, not to the
address given in the header.
RunAsUser=user [no short name] The user parameter may be a user name (looked up in
/etc/passwd) or a numeric user id; either form can have “:group” attached (where
group can be numeric or symbolic). If set to a non-zero (non-root) value, send-
mail will change to this user id shortly after startup22. This avoids a certain class
of security problems. However, this means that all “.forward” and “:include:”
files must be readable by the indicated user and all files to be written must be
writable by user Also, all file and program deliveries will be marked unsafe unless
the option DontBlameSendmail=NonRootSafeAddr is set, in which case the
delivery will be done as user. It is also incompatible with the SafeFileEnviron-
ment option. In other words, it may not actually add much to security on an aver-
age system, and may in fact detract from security (because other file permissions
must be loosened). However, it should be useful on firewalls and other places
where users don’t have accounts and the aliases file is well constrained.
RecipientFactor=fact
[y] The indicated factor is added to the priority (thus lowering the priority of the
job) for each recipient, i.e., this value penalizes jobs with large numbers of recipi-
ents. Defaults to 30000.
RefuseLA=LA [X] When the system load average exceeds LA, refuse incoming SMTP connec-
tions. Defaults to 12 multiplied by the number of processors online on the system
(if that can be determined).
RetryFactor=fact [Z] The factor is added to the priority every time a job is processed. Thus, each
time a job is processed, its priority will be decreased by the indicated value. In
most environments this should be positive, since hosts that are down are all too
often down for a long time. Defaults to 90000.
22
When running as a daemon, it changes to this user after accepting a connection but before reading any SMTP commands.
Sendmail Installation and Operation Guide SMM:08-61
SafeFileEnvironment=dir
[no short name] If this option is set, sendmail will do a chroot(2) call into the indi-
cated directory before doing any file writes. If the file name specified by the user
begins with dir, that partial path name will be stripped off before writing, so (for
example) if the SafeFileEnvironment variable is set to “/safe” then aliases of
“/safe/logs/file” and “/logs/file” actually indicate the same file. Additionally, if
this option is set, sendmail refuses to deliver to symbolic links.
SaveFromLine [f] Save UNIX-style “From” lines at the front of headers. Normally they are
assumed redundant and discarded.
SendMimeErrors [j] If set, send error messages in MIME format (see RFC2045 and RFC1344 for
details). If disabled, sendmail will not return the DSN keyword in response to an
EHLO and will not do Delivery Status Notification processing as described in
RFC1891.
ServerCertFile [no short name] File containing the certificate of the server, i.e., this certificate is
used when sendmail acts as server.
ServerKeyFile [no short name] File containing the private key belonging to the server certificate.
ServiceSwitchFile=filename
[no short name] If your host operating system has a service switch abstraction
(e.g., /etc/nsswitch.conf on Solaris or /etc/svc.conf on Ultrix and DEC OSF/1) that
service will be consulted and this option is ignored. Otherwise, this is the name
of a file that provides the list of methods used to implement particular services.
The syntax is a series of lines, each of which is a sequence of words. The 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 ServiceSwitchFile
is not specified, it defaults to /etc/mail/service.switch. If that file does not exist,
the default switch is:
aliases files
hosts dns nis files
The default file is “/etc/mail/service.switch”.
SevenBitInput [7] Strip input to seven bits for compatibility with old systems. This shouldn’t be
necessary.
SingleLineFromHeader
[no short name] If set, From: lines that have embedded newlines are unwrapped
onto one line. This is to get around a botch in Lotus Notes that apparently cannot
understand legally wrapped RFC822 headers.
SingleThreadDelivery
[no short name] If set, a client machine will never try to open two SMTP connec-
tions to a single server machine at the same time, even in different processes.
That is, if another sendmail is already talking to some host a new sendmail will
not open another connection. This property is of mixed value; although this
reduces the load on the other machine, it can cause mail to be delayed (for exam-
ple, if one sendmail is delivering a huge message, other sendmails won’t be able
to send even small messages). Also, it requires another file descriptor (for the
lock file) per connection, so you may have to reduce the ConnectionCacheSize
option to avoid running out of per-process file descriptors. Requires the HostSta-
tusDirectory option.
SMM:08-62 Sendmail Installation and Operation Guide
SmtpGreetingMessage=message
[$e macro] The message printed when the SMTP server starts up. Defaults to “$j
Sendmail $v ready at $b”.
StatusFile=file [S] Log summary statistics in the named file. If no file name is specified, "statis-
tics" is used. If not set, no summary statistics are saved. This file does not grow
in size. It can be printed using the mailstats(8) program.
SuperSafe [s] Be super-safe when running things, i.e., 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 really always be set.
TempFileMode=mode
[F] The file mode for queue files. It is interpreted in octal by default. Defaults to
0600.
Timeout.type= timeout
[r; subsumes old T option as well] Set timeout values. For more information, see
section 4.1.
TimeZoneSpec=tzinfo
[t] Set the local time zone info to tzinfo — for example, “PST8PDT”. Actually, if
this is not set, the TZ environment variable is cleared (so the system default is
used); if set but null, the user’s TZ variable is used, and if set and non-null the TZ
variable is set to this value.
TrustedUser=user[no short name] The user parameter may be a user name (looked up in
/etc/passwd) or a numeric user id. Trusted user for file ownership and starting the
daemon. If set, generated alias databases and the control socket (if configured)
will automatically be owned by this user.
TryNullMXList [w] If this system is the “best” (that is, lowest preference) MX for a given host, its
configuration rules should normally detect this situation and treat that condition
specially by forwarding the mail to a UUCP feed, treating it as local, or whatever.
However, in some cases (such as Internet firewalls) you may want to try to con-
nect 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 disrecommended.
UnixFromLine=fromline
[$l macro] Defines the format used when sendmail must add a UNIX-style From_
line (that is, a line beginning “From<space>user”). Defaults to “From $g $d”.
Don’t change this unless your system uses a different UNIX mailbox format (very
unlikely).
UnsafeGroupWrites
[no short name] If set, :include: and .forward files that are group writable are con-
sidered “unsafe”, that is, they cannot reference programs or write directly to files.
World writable :include: and .forward files are always unsafe..
UseErrorsTo [l] If there is an “Errors-To:” header, send error messages to the addresses listed
there. They normally go to the envelope sender. Use of this option causes send-
mail to violate RFC 1123. This option is disrecommended and 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
Sendmail Installation and Operation Guide SMM:08-63
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.
XscriptFileBufferSize=threshold
[no short name] Set the threshold, in bytes, before a memory-based queue tran-
script file becomes disk-based. The default is 4096 bytes.
All options can be specified on the command line using the −O or −o flag, but most will cause send-
mail to relinquish its setuid permissions. The options that will not cause this are SevenBitInput [7],
EightBitMode [8], MinFreeBlocks [b], CheckpointInterval [C], DeliveryMode [d], ErrorMode [e],
IgnoreDots [i], SendMimeErrors [j], LogLevel [L], MeToo [m], OldStyleHeaders [o], PrivacyOp-
tions [p], SuperSafe [s], Verbose [v], QueueSortOrder, MinQueueAge, DefaultCharSet, Dial Delay,
NoRecipientAction, ColonOkInAddr, MaxQueueRunSize, SingleLineFromHeader, and AllowBo-
gusHELO. Actually, PrivacyOptions [p] given on the command line are added to those already
specified in the sendmail.cf file, i.e., they can’t be reset. Also, M (define macro) when defining the r
or s macros is also considered “safe”.
23
And of course, vendors are encouraged to add themselves to the list of recognized vendors by editing the routine setvendor in
conf.c. Please send e-mail to [email protected] to register your vendor dialect.
Sendmail Installation and Operation Guide SMM:08-65
function. If it returns a value, it replaces the input. If it does not return a value and the default is
specified, the default replaces the input. Otherwise, the input is unchanged.
The arguments are passed to the map for arbitrary use. Most map classes can interpolate
these arguments into their values using the syntax “%n” (where n is a digit) to indicate the corre-
sponding argument. Argument “%0” indicates the database key. For example, the rule
R$− ! $+ $: $(uucp $1 $@ $2 $: %1 @ %0 . UUCP $)
Looks up the UUCP name in a (user 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
Note that default clauses never do this mapping.
The built in map with both name and class “host” is the host name canonicalization lookup.
Thus, the syntax:
$(host hostname$)
is equivalent to:
$[hostname$]
user Looks up users using getpwnam(3). The −v flag can be used to specify the name
of the field to return (although this is normally used only to check the existence of
a user).
host Canonifies host domain names. Given a host name it calls the name server to find
the canonical name for that host.
bestmx Returns the best MX record for a host name given as the key. The current
machine is always preferred — that is, if the current machine is one of the hosts
listed as a lowest-preference MX record, then it will be guaranteed to be returned.
This can be used to find out if this machine is the target for an MX record, and
mail can be accepted on that basis. If the −z flag is given, then all MX names are
returned, separated by the given delimiter.
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.
syslog the key is logged via syslogd (8). The lookup returns the empty string.
switch Much like the “sequence” map except that the order of maps is determined by the
service switch. The argument is the name of the service to be looked up; the val-
ues 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 backslashes, and will not
strip quotes if the resulting string would contain unscannable syntax (that is, basic
errors like unbalanced angle brackets; more sophisticated errors such as unknown
hosts are not checked). The intent is for use when trying to accept mail from sys-
tems such as DECnet that 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.
Sendmail Installation and Operation Guide SMM:08-67
regex The map definition on the K line contains a regular expression. Any key input is
compared to that expression using the POSIX regular expressions routines reg-
comp(), regerr(), and regexec(). Refer to the documentation for those routines for
more information about the regular expression matching. No rewriting of the key
is done if the −m flag is used. Without it, the key is discarded or if −s if used, it is
substituted by the substring matches, delimited by $| or the string specified with
the the −d flag. The flags available for the map are
-n not
-f case sensitive
-b basic regular expressions
(default is extended)
-s substring match
-d set the delimiter used for -s
-a append string to key
-m match only, do not
replace/discard value
-D perform no lookup in deferred delivery mode.
The −s flag can include an optional parameter which can be used to select the sub-
strings in the result of the lookup. For example,
-s1,3,4
Notes: to match a $ in a string, \$$ must be used. If the pattern contains spaces,
they must be replaced with the blank substitution character, unless it is space
itself.
program The arguments on the K line are the pathname to a program and any initial param-
eters to be passed. When the map is called, the key is added to the initial parame-
ters and the program is invoked as the default user/group id. The first line of stan-
dard output is returned as the value of the lookup. This has many potential secu-
rity problems, and has terrible performance; it should be used only when abso-
lutely necessary.
macro Set or clear a macro value. To set a macro, pass the value as the first argument in
the map lookup. To clear a macro, do not pass an argument in the map lookup.
The map always returns the empty string. Example of typical usage include:
Kstorage macro
...
arith Perform simple arithmetic operations. The operation is given as key, currently +,
-, *, /, l (for less than), and = are supported. The two operands are given as argu-
ments. The lookup returns the result of the computation, i.e. TRUE or FALSE for
comparisons, integer values otherwise. All options which are possible for maps
are ignored. A simple example is:
SMM:08-68 Sendmail Installation and Operation Guide
Kcomp arith
...
Scheck_etrn
R$* $: $(comp l $@ $&{load_avg} $@ 7 $) $1
RFALSE $# error ...
Most of these 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:
−o Indicates that this map is optional — that is, if it cannot be opened, no error is
produced, and sendmail will behave as if the map existed but was empty.
−N, −O If neither −N or −O are 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 are 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.
−Tx Append the string x on temporary failures. For example, x would be appended if a
DNS lookup returned “server failed” or an NIS lookup could not locate a server.
See also the −t flag.
−f Do not fold upper to lower case 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 text lookups). For LDAP maps
this is an LDAP filter string in which %s is replaced with the literal contents of
the lookup key and %0 is replaced with the LDAP escaped contents of the lookup
key according to RFC2254.
−vvalcol The value column name (for NIS+) or number (for text lookups). For LDAP
maps this is the name of one or more attributes to be returned; multiple attributes
can be separated by commas. If not specified, all attributes found in the match
will be returned.
−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. For LDAP maps
this is the separator character to combine multiple values into a single return
string. If not set, the LDAP lookup will only return the first match found.
−t Normally, when a map attempts to do a lookup and the server fails (e.g., sendmail
couldn’t contact any name server; this is not the same as an entry not being found
in the map), the message being processed is queued for future processing. The −t
flag turns off this behavior, letting the temporary failure (server down) act as
though it were a permanent failure (entry not found). It is particularly useful for
DNS lookups, where someone else’s misconfigured name server can cause
Sendmail Installation and Operation Guide SMM:08-69
problems on your machine. However, care must be taken to ensure that you don’t
bounce mail that would be resolved correctly if you tried again. A common strat-
egy is to forward such mail to another, possibly better connected, mail server.
−D Perform no lookup in deferred delivery mode. This flag is set by default for the
host map.
−Sspacesub The character to use to replace space characters after a successful map lookup
(esp. useful for regex and syslog maps).
−sspacesub For the dequote map only, the character to use to replace space characters after a
successful dequote.
−q Don’t dequote the key before lookup.
−Llevel For the syslog map only, it specifies the level to use for the syslog call.
−A When rebuilding an alias file, the −A flag causes duplicate entries in the text ver-
sion to be merged. For example, two entries:
list: user1, user2
list: user3
would be treated as though it were the single entry
list: user1, user2, user3
in the presence of the −A flag.
The following additional flags are present in the ldap map only:
−R Do not auto chase referrals. sendmail must be compiled with −DLDAP_REFER-
RALS to use this flag.
−n Retrieve attribute names only.
−rderef Set the alias dereference option to one of never, always, search, or find.
−sscope Set search scope to one of base, one (one level), or sub (subtree).
−hhost LDAP server hostname. Some LDAP libraries allow you to specify multiple,
space-separated hosts for redundancy. In addition, each of the hosts listed can be
followed by a colon and a port number to override the default LDAP port.
−bbase LDAP search base.
−pport LDAP service port.
−ltimelimit Time limit for LDAP queries.
−Zsizelimit Size (number of matches) limit for LDAP queries.
−ddistinguished_name
The distinguished name to use to login to the LDAP server.
−Mmethod The method to authenticate to the LDAP server. Should be one of
LDAP_AUTH_NONE, LDAP_AUTH_SIMPLE, or LDAP_AUTH_KRBV4.
−Ppasswordfile The file containing the secret key for the LDAP_AUTH_SIMPLE authentication
method or the name of the Kerberos ticket file for LDAP_AUTH_KRBV4.
−1 Force LDAP searches to only succeed if a single match is found. If multiple val-
ues are found, the search is treated as if no match was found.
The dbm map appends the strings “.pag” and “.dir” to the given filename; the hash and btree
maps append “.db”. For example, the map specification
Kuucp dbm −o −N /etc/mail/uucpmap
specifies an optional map named “uucp” of class “dbm”; it always has null bytes at the end of every
string, and the data is located in /etc/mail/uucpmap.{dir,pag}.
SMM:08-70 Sendmail Installation and Operation Guide
The program makemap(8) can be used to build any of the three database-oriented maps. It
takes the following flags:
−f Do not fold upper to lower case 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 won’t be read while they are being updated.
New classes can be added in the routine setupmaps in file conf.c.
As of this writing, only a few of these fields are actually being used by sendmail: mail-
drop and mailname. A finger program that uses the other fields is planned.
6. OTHER CONFIGURATION
There are some configuration changes that 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 this
should be unnecessary unless you are porting sendmail to a new environment.
24
These instructions are known to be incomplete. Other features are available which provide similar functionality, e.g., virtual
hosting and mapping local addresses into a generic form as explained in cf/README.
SMM:08-72 Sendmail Installation and Operation Guide
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, configura-
tion file lines, alias lines, etc., must fit within this limit.
MAXNAME [256] The maximum length of any name, such as a host or a user name.
MAXPV [256] The maximum number of parameters to any mailer. This limits the number of
recipients that may be passed in one transaction. It can be set to any arbitrary
number above about 10, since sendmail will break up a delivery into smaller
batches as needed. A higher number may reduce load on your system, how-
ever.
MAXATOM [1000] The maximum number of atoms (tokens) in a single address. For example, the
address “[email protected]” is seven atoms.
MAXMAILERS [25]The maximum number of mailers that may be defined in the configuration file.
This value is defined in include/sendmail/sendmail.h.
MAXRWSETS [200]The maximum number of rewriting sets that may be defined. The first half of
these are reserved for numeric specification (e.g., ‘‘S92’’), while the upper half
are reserved for auto-numbering (e.g., ‘‘Sfoo’’). Thus, with a value of 200 an
attempt to use ‘‘S99’’ will succeed, but ‘‘S100’’ will fail.
MAXPRIORITIES [25]
The maximum number of values for the “Precedence:” field that may be
defined (using the P line in sendmail.cf).
MAXUSERENVIRON [100]
The maximum number of items in the user environment that will be passed to
subordinate mailers.
MAXMXHOSTS [100]
The maximum number of MX records we will accept for any single host.
MAXALIASDB [12]The maximum number of alias databases that can be open at any time. Note
that there may also be an open 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; addi-
tional 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 compo-
nents in a single Multipart document).
MAXDAEMONS [10]
The maximum number of sockets sendmail will open for accepting connec-
tions on different ports.
MAXMACNAMELEN [25]
The maximum length of a macro name.
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 ver-
sions of sendmail referred to this as DAEMON; this old usage is now incorrect.
Defaults on; turn it off in the Makefile if your system doesn’t support the
SMM:08-74 Sendmail Installation and Operation Guide
Internet protocols.
NETINET6† If set, support for IPv6 networking is compiled in. It must be separately
enabled by adding DaemonPortOptions settings.
NETISO† If set, support for ISO protocol networking is compiled in (it may be appropri-
ate to #define this in the Makefile instead of conf.h).
NETUNIX† If set, support for UNIX domain sockets is compiled in. This is used for con-
trol socket support.
LOG If set, the syslog routine in use at some sites is used. This makes an informa-
tional 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† Compile in the code to do ‘‘fuzzy matching’’ on the GECOS field in
/etc/passwd. This also requires that the MatchGECOS option be turned on.
NAMED_BIND† Compile 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 spe-
cial processing of UNIX-style “From ” lines.
QUEUE† This flag should be set to compile in the queueing code. If this is not set,
mailers must accept the mail immediately or it will be returned to the sender.
SMTP† If set, the code to handle user and server SMTP will be compiled in. This is
only necessary if your machine has some mailer that speaks SMTP (this
means most machines everywhere).
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† Compile in the IDENT protocol as defined in RFC 1413. This defaults on for
all systems except Ultrix, which apparently has the interesting “feature” that
when it receives a “host unreachable” message it closes all open connections
to that host. Since some firewall gateways send this error code when you
access an unauthorized port (such as 113, used by IDENT), Ultrix cannot
receive email from such hosts.
SYSTEM5 Set all of the compilation parameters appropriate for System V.
HASFLOCK† Use Berkeley-style flock instead of System V lockf to do file locking. Due to
the highly unusual semantics of locks across forks in lockf, this should always
be used if at all possible.
HASINITGROUPS 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 rou-
tine). Set by default if SYSTEM5 is set.
HASGETDTABLESIZE
Set this if you have the getdtablesize(2) system call.
HASWAITPID Set this if you have the haswaitpid(2) system call.
FAST_PID_RECYCLE
Set this if your system can possibly reuse the same pid in the same second of
Sendmail Installation and Operation Guide SMM:08-75
time.
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) syscall), SFS_4ARGS (use
the four argument statfs(2) syscall), SFS_VFS (use the two argument statfs(2)
syscall including <sys/vfs.h>), SFS_MOUNT (use the two argument statfs(2)
syscall including <sys/mount.h>), SFS_STATFS (use the two argument
statfs(2) syscall including <sys/statfs.h>), SFS_STATVFS (use the two argu-
ment statfs(2) syscall including <sys/statvfs.h>), or SFS_NONE (no way to
get this information).
LA_TYPE The load average type. Details are described below.
The are several built-in ways of computing the load average. Sendmail tries to auto-configure them
based on imperfect guesses; you can select one using the cc option −DLA_TYPE=type, where type
is:
LA_INT The kernel stores the load average in the kernel as an array of long integers.
The actual values are scaled by a factor FSCALE (default 256).
LA_SHORT The kernel stores the load average in the kernel as an array of short integers.
The actual values are scaled by a factor FSCALE (default 256).
LA_FLOAT The kernel stores the load average in the kernel 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”).
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 assump-
tion 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 mes-
sage.
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:).
Let’s look at a 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,
"errors-to", H_FROM | H_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 automati-
cally 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
Sendmail Installation and Operation Guide SMM:08-77
cliched processing; certain headers are processed specially by ad hoc code regardless of the sta-
tus specified in HdrInfo. For example, the “Sender:” and “From:” fields are always scanned on
ARPANET mail to determine the sender25; this is used to perform the “return to sender” func-
tion. 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.
7. ACKNOWLEDGEMENTS
I’ve worked on sendmail for many years, and many employers have been remarkably patient
about letting me work on a large project that was not part of my official job. This includes time on the
INGRES Project at the University of California at Berkeley, at Britton Lee, and again on the Mammoth
26
If you do, please send updates to [email protected].
SMM:08-80 Sendmail Installation and Operation Guide
Arguments must be presented with flags before addresses. The flags are:
−bx Set operation mode to x. Operation modes are:
m Deliver mail (default)
s Speak SMTP on input side
a† ‘‘Arpanet’’ mode (get envelope sender information from header)
d Run as a daemon in background
D Run as a daemon in foreground
t Run in test mode
v Just verify addresses, don’t collect or deliver
i Initialize the alias database
p Print the mail queue
h Print the persistent host status database
H Purge expired entries from the persistent host status database
†Deprecated.
for successful delivery, failure, and a message that is stuck in a queue somewhere. The
default is “FAILURE,DELAY”.
−r addr An obsolete form of −f.
−ox value Set option x to the specified value. These options are described in Section 5.6.
−Ooption=value Set option to the specified value (for long form option names). These options are
described in Section 5.6.
−Mx value Set macro x to the specified value.
−pprotocol Set 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 Try to process the queued up mail. If the time is given, a sendmail will run through the
queue at the specified interval to deliver queued mail; otherwise, it only runs once.
−qXstring Run 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 con-
tains the indicated string. Multiple −qX flags are permitted, with items with the same key
letter “or’ed” together, and items with different key letters “and’ed” together.
−R ret What information you want returned if the message bounces; ret can be “HDRS” for
headers only or “FULL” for headers plus body. This is a request only; the other end is
not required to honor the parameter. If “HDRS” is specified local bounces also return
only the headers.
−t Read the header for “To:”, “Cc:”, and “Bcc:” lines, and send to everyone listed in those
lists. The “Bcc:” line will be deleted before sending. Any addresses in the argument vec-
tor will be deleted from the send list.
−U Indicate that this is an initial User Agent submission. This flag is deprecated. Future
releases will ignore this flag and assume all submissions from the command line are ini-
tial submissions.
−V envid The indicated envid is passed with the envelope of the message and returned if the mes-
sage bounces.
−X logfile Log all traffic in and out of sendmail in the indicated logfile for debugging mailer prob-
lems. This produces a lot of data very quickly and should be used sparingly.
There are a number of options that may be specified as primitive flags. These are the e, i, m, and v
options. Also, the f option may be specified as the −s flag. The DSN related options “−N”, “−R”, and
“−V” have no effects on sendmail running as daemon.
APPENDIX B
This appendix describes the format of the queue 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. The individual qf, df, and
xf files may be stored in separate qf/, df/, and xf/ subdirectories if they are present in the queue directory.
To use multiple queues, supply a value ending with an asterisk. For example, /var/spool/mqueue/q*
will use all of the directories or symbolic links to directories beginning with ‘q’ in /var/spool/mqueue as
queue directories. New messages will be randomly placed into one of the queues. Do not change the
queue directory structure while sendmail is running.
All queue files have the name x fYMDhmsNPPPPP where YMDhmsNPPPPP is the id for this mes-
sage and the x is a type. The individual letters in the id are:
Y Encoded year
M Encoded month
D Encoded day
h Encoded hour
m Encoded minute
s Encoded second
N Envelope number
PPPPP At least five digits of the process ID
All files with the same id collectively define one message. If memory-buffered files are available,
some of these files may never appear on disk.
The types are:
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 fol-
lows:
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.
For 8.10 the version number is 4.
A The information given by the AUTH= parameter of the “MAIL FROM:” command or $f@$j if
sendmail has been called directly.
H A header definition. There may be any number of these lines. The order is important: they repre-
sent the order in the final message. These use the same syntax as header definitions in the configu-
ration 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 print-
ing messages).
Q The ‘‘original recipient’’, specified by the ORCPT= field in an ESMTP transaction. Used exclu-
sively for Delivery Status Notifications. It applies only to the immediately following ‘R’ line.
R A recipient address. This will normally be completely aliased, but is actually realiased when the
job is processed. There will be one line for each recipient. Version 1 qf files also include a lead-
ing colon-terminated list of flags, which can be ‘S’ to return a message on successful final deliv-
ery, ‘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 may only be 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 priori-
ties. 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 infor-
mation. It can contain any text.
F Flag bits, represented as one 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 announcing 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 (as of this writing, only $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”.
Z The original envelope id (from the ESMTP transaction). For Deliver Status Notifications only.
As an example, the following is a queue file sent to “[email protected]” and
“[email protected]”1:
1
This example is contrived and probably inaccurate for your environment. Glance over it to get an idea; nothing can replace
looking at what your own system generates.
Sendmail Installation and Operation Guide SMM:08-85
V4
T711358135
K904446490
N0
P2100941
$_eric@localhost
${daemon_flags}
Seric
Ceric:100:1000:[email protected]
RPFD:[email protected]
RPFD:[email protected]
H?P?Return-path: <ˆg>
H??Received: by vangogh.CS.Berkeley.EDU (5.108/2.7) id AAA06703;
Fri, 17 Jul 1992 00:28:55 -0700
H??Received: from mail.CS.Berkeley.EDU by vangogh.CS.Berkeley.EDU (5.108/2.7)
id AAA06698; Fri, 17 Jul 1992 00:28:54 -0700
H??Received: from [128.32.31.21] by mail.CS.Berkeley.EDU (5.96/2.5)
id AA22777; Fri, 17 Jul 1992 03:29:14 -0400
H??Received: by foo.bar.baz.de (5.57/Ultrix3.0-C)
id AA22757; Fri, 17 Jul 1992 09:31:25 GMT
H?F?From: [email protected] (Eric Allman)
H?x?Full-name: Eric Allman
H??Message-id: <[email protected]>
H??To: [email protected]
H??Subject: this is an example message
This shows the person who sent the message, the submission time (in seconds since January 1, 1970), the
message priority, the message class, the recipients, and the headers for the message.
APPENDIX C
This is a summary of the support files that sendmail creates or generates. Many of these can be
changed by editing the sendmail.cf file; check there to find the actual pathnames.
/usr/sbin/sendmail
The binary of sendmail.
/usr/bin/newaliases
A link to /usr/sbin/sendmail; causes the alias database to be rebuilt. Running this pro-
gram is completely equivalent to giving sendmail the −bi flag.
/usr/bin/mailq Prints a listing of the mail queue. This program is equivalent to using the −bp flag to
sendmail.
/etc/mail/sendmail.cf
The configuration file, in textual form.
/etc/mail/helpfile The SMTP help file.
/etc/mail/statistics
A statistics file; need not be present.
/etc/mail/sendmail.pid
Created in daemon mode; it contains the process id of the current SMTP daemon. If you
use this in scripts; use ‘‘head −1’’ to get just the first line; the second line contains the
command line used to invoke the daemon, and later versions of sendmail may add more
information to subsequent lines.
/etc/mail/aliases The textual version of the alias file.
/etc/mail/aliases.db
The alias file in hash (3) format.
/etc/mail/aliases.{pag,dir}
The alias file in ndbm (3) format.
/var/spool/mqueue
The directory in which the mail queue(s) 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 rebuild.
/var/spool/mqueue/xf*
A transcript of the current session.
TABLE OF CONTENTS