8.17.1

8.17.2

8.18.1

SENDMAILTM

INSTALLATION AND OPERATION GUIDE

Eric Allman

Claus Assmann

Gregory Neil Shapiro

Proofpoint, Inc.

For Sendmail Version 8.17

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 conguration le.

Due to the requirements of exibility for sendmail, the conguration le can seem somewhat unap-

proachable. However, there are only a few basic congurations for most sites, for which standard congu-

ration les have been supplied. Most other congurations can be built by adjusting an existing congura-

tion le incrementally.

Sendmail is based on RFC 821 (Simple Mail Transport Protocol), RFC 822 (Internet Mail Headers

Format), RFC 974 (MX routing), RFC 1123 (Internet Host Requirements), RFC 1413 (Identication

server), RFC 1652 (SMTP 8BITMIME Extension), RFC 1869 (SMTP Service Extensions), RFC 1870

(SMTP SIZE Extension), RFC 1891 (SMTP Delivery Status Notications), RFC 1892 (Multipart/Report),

RFC 1893 (Enhanced Mail System Status Codes), RFC 1894 (Delivery Status Notications), RFC 1985

(SMTP Service Extension for Remote Message Queue Starting), RFC 2033 (Local Message Transmission

Protocol), RFC 2034 (SMTP Service Extension for Returning Enhanced Error Codes), RFC 2045 (MIME),

RFC 2476 (Message Submission), RFC 2487 (SMTP Service Extension for Secure SMTP over TLS), RFC

2554 (SMTP Service Extension for Authentication), RFC 2821 (Simple Mail Transfer Protocol), RFC 2822

(Internet Message Format), RFC 2852 (Deliver By SMTP Service Extension), RFC 2920 (SMTP Service

Extension for Command Pipelining), and RFC 7505 (A "Null MX" No Service Resource Record for Do-

mains That Accept No Mail). However, since sendmail is designed to work in a wider world, in many cases

it can be congured to exceed these protocols. These cases are described herein.

Although sendmail is intended to run without the need for monitoring, it has a number of features

that may be used to monitor or adjust the operation under unusual circumstances. These features are de-

scribed.

Section one describes how to do a basic sendmail installation. Section two explains the day-to-day

information you should know to maintain your mail system. If you have a relatively normal site, these two

sections should contain sufcient information for you to install sendmail and keep it happy. Section three

has information regarding the command line arguments. Section four describes some parameters that may

DISCLAIMER: This documentation is under modication.

Sendmail is a trademark of Proofpoint, Inc. US Patent Numbers 6865671, 6986037.

Sendmail Installation and Operation Guide

SMM:08-1

SMM:08-2

Sendmail Installation and Operation Guide

be safely tweaked. Sectionve contains the nitty-gritty information about the conguration le. This sec-

tion is for masochists and people who must write their own conguration le. Section six describes cong-

uration that can be done at compile time. The appendixes give a brief but detailed explanation of a number

of features not described in the rest of the paper.

Sendmail Installation and Operation Guide

SMM:08-3

TABLE OF CONTENTS

1. BASIC INSTALLATION ...............................................................................................................

7

1.1. Compiling Sendmail ..............................................................................................................

7

1.1.1. Tweaking the Build Invocation .....................................................................................

7

1.1.2. Creating a Site Conguration File ................................................................................

7

1.1.3. Tweaking the Makele .................................................................................................

8

1.1.4. Compilation and installation ........................................................................................

8

1.2. Conguration Files ................................................................................................................

8

1.3. Details of Installation Files ...................................................................................................

9

1.3.1. /usr/sbin/sendmail .........................................................................................................

10

1.3.2. /etc/mail/sendmail.cf ....................................................................................................

10

1.3.3. /etc/mail/submit.cf ........................................................................................................

10

1.3.4. /usr/bin/newaliases .......................................................................................................

10

1.3.5. /usr/bin/hoststat ............................................................................................................

10

1.3.6. /usr/bin/purgestat ..........................................................................................................

10

1.3.7. /var/spool/mqueue ........................................................................................................

11

1.3.8. /var/spool/clientmqueue ...............................................................................................

11

1.3.9. /var/spool/mqueue/.hoststat ..........................................................................................

11

1.3.10. /etc/mail/aliases* ........................................................................................................

11

1.3.11. /etc/rc or /etc/init.d/sendmail ......................................................................................

12

1.3.12. /etc/mail/helple .........................................................................................................

12

1.3.13. /etc/mail/statistics .......................................................................................................

12

1.3.14. /usr/bin/mailq .............................................................................................................

12

1.3.15. sendmail.pid ...............................................................................................................

12

1.3.16. Map Files ....................................................................................................................

14

2. NORMAL OPERATIONS .............................................................................................................

14

2.1. The System Log ....................................................................................................................

14

2.1.1. Format ..........................................................................................................................

14

2.1.2. Levels ...........................................................................................................................

15

2.2. Dumping State .......................................................................................................................

15

2.3. The Mail Queues ...................................................................................................................

15

2.3.1. Queue Groups and Queue Directories ..........................................................................

16

2.3.2. Queue Runs ..................................................................................................................

16

2.3.3. Manual Intervention .....................................................................................................

17

2.3.4. Printing the queue .........................................................................................................

17

2.3.5. Forcing the queue .........................................................................................................

17

2.3.6. Quarantined Queue Items .............................................................................................

18

2.4. Disk Based Connection Information .....................................................................................

18

2.5. The Service Switch ................................................................................................................

19

2.6. The Alias Database ................................................................................................................

20

2.6.1. Rebuilding the alias database .......................................................................................

21

2.6.2. Potential problems ........................................................................................................

21

2.6.3. List owners ...................................................................................................................

21

SMM:08-4

Sendmail Installation and Operation Guide

2.7. User Information Database ....................................................................................................

22

2.8. Per-User Forwarding (.forward Files) ...................................................................................

22

2.9. Special Header Lines .............................................................................................................

22

2.9.1. Errors-To: .....................................................................................................................

22

2.9.2. Apparently-To: .............................................................................................................

22

2.9.3. Precedence ....................................................................................................................

22

2.10. IDENT Protocol Support .....................................................................................................

23

3. ARGUMENTS ...............................................................................................................................

23

3.1. Queue Interval .......................................................................................................................

23

3.2. Daemon Mode .......................................................................................................................

24

3.3. Forcing the Queue .................................................................................................................

24

3.4. Debugging .............................................................................................................................

24

3.5. Changing the Values of Options ............................................................................................

25

3.6. Trying a Different Conguration File ...................................................................................

25

3.7. Logging Trafc ......................................................................................................................

25

3.8. Testing Conguration Files ...................................................................................................

26

3.9. Persistent Host Status Information ........................................................................................

27

4. TUNING .........................................................................................................................................

27

4.1. Timeouts ................................................................................................................................

27

4.1.1. Queue interval ..............................................................................................................

27

4.1.2. Read timeouts ...............................................................................................................

28

4.1.3. Message timeouts .........................................................................................................

29

4.2. Forking During Queue Runs .................................................................................................

30

4.3. Queue Priorities .....................................................................................................................

30

4.4. Load Limiting ........................................................................................................................

31

4.5. Resource Limits .....................................................................................................................

31

4.6. Measures against Denial of Service Attacks .........................................................................

31

4.7. Delivery Mode .......................................................................................................................

31

4.8. Log Level ...............................................................................................................................

32

4.9. File Modes .............................................................................................................................

33

4.9.1. To suid or not to suid? .................................................................................................

33

4.9.2. Turning off security checks ..........................................................................................

33

4.10. Connection Caching ............................................................................................................

35

4.11. Name Server Access ............................................................................................................

36

4.12. Moving the Per-User Forward Files ....................................................................................

37

4.13. Free Space ...........................................................................................................................

37

4.14. Maximum Message Size .....................................................................................................

37

4.15. Privacy Flags .......................................................................................................................

37

4.16. Send to Me Too ...................................................................................................................

38

5. THE WHOLE SCOOP ON THE CONFIGURATION FILE ........................................................

38

5.1. R and S — Rewriting Rules ..................................................................................................

38

5.1.1. The left hand side .........................................................................................................

39

5.1.2. The right hand side .......................................................................................................

39

5.1.3. Semantics of rewriting rule sets ...................................................................................

40

Sendmail Installation and Operation Guide

SMM:08-5

5.1.4. Ruleset hooks ...............................................................................................................

41

5.1.4.1. check_relay ..........................................................................................................

41

5.1.4.2. check_mail ..........................................................................................................

42

5.1.4.3. check_rcpt ...........................................................................................................

42

5.1.4.4. check_data ...........................................................................................................

42

5.1.4.5. check_other .........................................................................................................

42

5.1.4.6. check_compat ......................................................................................................

42

5.1.4.7. check_eoh ............................................................................................................

42

5.1.4.8. check_eom ...........................................................................................................

43

5.1.4.9. check_etrn ...........................................................................................................

43

5.1.4.10. check_expn ........................................................................................................

43

5.1.4.11. check_vrfy .........................................................................................................

43

5.1.4.12. clt_features ........................................................................................................

43

5.1.4.13. trust_auth ...........................................................................................................

44

5.1.4.14. tls_client ............................................................................................................

44

5.1.4.15. tls_server ...........................................................................................................

44

5.1.4.16. tls_rcpt ...............................................................................................................

44

5.1.4.17. srv_features .......................................................................................................

44

5.1.4.18. try_tls .................................................................................................................

45

5.1.4.19. tls_srv_features and tls_clt_features .................................................................

45

5.1.4.20. authinfo ..............................................................................................................

46

5.1.4.21. queuegroup ........................................................................................................

46

5.1.4.22. greet_pause ........................................................................................................

47

5.1.5. IPC mailers ...................................................................................................................

47

5.2. D — Dene Macro ................................................................................................................

47

5.3. C and F — Dene Classes .....................................................................................................

54

5.4. M — Dene Mailer ...............................................................................................................

56

5.5. H — Dene Header ...............................................................................................................

61

5.6. O — Set Option .....................................................................................................................

62

5.7. P — Precedence Denitions ..................................................................................................

81

5.8. V — Conguration Version Level .........................................................................................

81

5.9. K — Key File Declaration .....................................................................................................

82

5.10. Q — Queue Group Declaration ...........................................................................................

90

5.11. X — Mail Filter (Milter) Denitions ..................................................................................

92

5.12. The User Database ..............................................................................................................

92

5.12.1. Structure of the user database .....................................................................................

93

5.12.2. User database semantics .............................................................................................

93

5.12.3. Creating the database23 ...............................................................................................

94

6. OTHER CONFIGURATION .........................................................................................................

94

6.1. Parameters in devtools/OS/$oscf ...........................................................................................

94

6.1.1. For Future Releases ......................................................................................................

95

6.2. Parameters in sendmail/conf.h ..............................................................................................

95

6.3. Conguration in sendmail/conf.c ..........................................................................................

98

6.3.1. Built-in Header Semantics ...........................................................................................

98

SMM:08-6

Sendmail Installation and Operation Guide

6.3.2. Restricting Use of Email ..............................................................................................

99

6.3.3. New Database Map Classes .........................................................................................

100

6.3.4. Queueing Function .......................................................................................................

100

6.3.5. Refusing Incoming SMTP Connections .......................................................................

101

6.3.6. Load Average Computation ..........................................................................................

101

6.4. Conguration in sendmail/daemon.c .....................................................................................

101

6.5. LDAP .....................................................................................................................................

102

6.5.1. LDAP Recursion ..........................................................................................................

102

6.5.1.1. Example ...............................................................................................................

102

6.6. STARTTLS ............................................................................................................................

103

6.6.1. Certicates for STARTTLS ..........................................................................................

103

6.6.2. PRNG for STARTTLS .................................................................................................

103

6.7. Encoding of STARTTLS and AUTH related Macros ............................................................

104

6.8. DANE ....................................................................................................................................

104

6.9. EAI ........................................................................................................................................

104

6.10. MTA-STS ............................................................................................................................

105

7. ACKNOWLEDGEMENTS ............................................................................................................

105

Appendix A. COMMAND LINE FLAGS .........................................................................................

107

Appendix B. QUEUE FILE FORMATS ............................................................................................

110

Appendix C. SUMMARY OF SUPPORT FILES ..............................................................................

113

Sendmail Installation and Operation Guide

SMM:08-7

1. BASIC INSTALLATION

There are two basic steps to installing sendmail. First, you have to compile and install the binary.

If sendmail has already been ported to your operating system that should be simple. Second, you must

build a run-time conguration le. This is a le that sendmail reads when it starts up that describes the

mailers it knows about, how to parse addresses, how to rewrite the message header, and the settings of

various options. Although the conguration le can be quite complex, a conguration can usually be

built using an M4-based conguration language. Assuming you have the standard sendmail distribu-

tion, see cf/README for further information.

The remainder of this section will describe the installation of sendmail assuming you can use one

of the existing congurations and that the standard installation parameters are acceptable. All path-

names and examples are given from the root of the sendmail subtree, normally /usr/src/usr.sbin/send-

mail on 4.4BSD-based systems.

Continue with the next section if you need/want to compile sendmail yourself. If you have a run-

ning binary already on your system, you should probably skip to section 1.2.

1.1. Compiling Sendmail

All sendmail source is in the sendmail subdirectory. To compile sendmail, “cd” into the send-

mail directory and type

./Build

This will leave the binary in an appropriately named subdirectory, e.g., obj.BSD-OS.2.1.i386. It

works for multiple object versions compiled out of the same directory.

1.1.1. Tweaking the Build Invocation

You can give parameters on the Build command. In most cases these are only used when

the obj.* directory is rst created. To restart from scratch, use -c. These commands include:

L libdirs

A list of directories to search for libraries.

I incdirs

A list of directories to search for include les.

E envar=value

Set an environment variable to an indicated value before compiling.

c

Create a new obj.* tree before running.

f sitecong

Read the indicated site conguration le. If this parameter is not specied, Build in-

cludes

all

of

the

les

$BUILDTOOLS/Site/site.$oscf.m4

and

$BUILD-

TOOLS/Site/site.cong.m4, where $BUILDTOOLS is normally ../devtools and $oscf is

the same name as used on the obj.* directory. See below for a description of the site

conguration le.

S

Skip auto-conguration. Build will avoid auto-detecting libraries if this is set. All li-

braries and map denitions must be specied in the site conguration le.

Most other parameters are passed to the

make

program; for details see

$BUILD-

TOOLS/README.

1.1.2. Creating a Site Conguration File

See sendmail/README for various compilation ags that can be set, and dev-

tools/README for details how to set them.

SMM:08-8

Sendmail Installation and Operation Guide

1.1.3. Tweaking the Makele

Sendmail supports two different formats for the local (on disk) version of databases, no-

tably the aliases database. At least one of these should be dened if at all possible.

CDB

Constant DataBase (tinycdb).

NDBM

The ‘‘new DBM’’ format, available on nearly all systems around today. This

was the preferred format prior to 4.4BSD. It allows such complex things as

multiple databases and closing a currently open database.

NEWDB

The Berkeley DB package. If you have this, use it. It allows long records,

multiple open databases, real in-memory caching, and so forth. You can de-

ne this in conjunction with NDBM; if you do, old alias databases are read, but

when a new database is created it will be in NEWDB format. As a nasty hack,

if you have NEWDB, NDBM, and NIS dened, and if the alias le name in-

cludes the substring “/yp/”, sendmail will create both new and old versions of

the alias le during a newalias command. This is required because the Sun

NIS/YP system reads the DBM version of the alias le. It’s ugly as sin, but it

works.

If neither of these are dened, sendmail reads the alias le into memory on every invocation.

This can be slow and should be avoided. There are also several methods for remote database ac-

cess:

LDAP

Lightweight Directory Access Protocol.

NIS

Sun’s Network Information Services (formerly YP).

NISPLUS

Sun’s NIS+ services.

NETINFO

NeXT’s NetInfo service.

HESIOD

Hesiod service (from Athena).

Other compilation ags are set in conf.h and should be predened for you unless you are porting

to a new environment. For more options see sendmail/README.

1.1.4. Compilation and installation

After making the local system conguration described above, You should be able to com-

pile and install the system. The script “Build” is the best approach on most systems:

./Build

This will use uname(1) to create a custom Makele for your environment.

If you are installing in the standard places, you should be able to install using

./Build install

This should install the binary in /usr/sbin and create links from /usr/bin/newaliases and

/usr/bin/mailq to /usr/sbin/sendmail. On most systems it will also format and install man pages.

Notice: as of version 8.12 sendmail will no longer be installed set-user-ID root by default. If

you really want to use the old method, you can specify it as target:

./Build install-set-user-id

1.2. Conguration Files

Sendmail cannot operate without a conguration le. The conguration denes the mail de-

livery mechanisms understood at this site, how to access them, how to forward email to remote mail

systems, and a number of tuning parameters. This conguration le is detailed in the later portion

of this document.

Sendmail Installation and Operation Guide

SMM:08-9

The sendmail conguration can be daunting at rst. The world is complex, and the mail con-

guration reects that. The distribution includes an m4-based conguration package that hides a lot

of the complexity. See cf/README for details.

Our conguration les are processed by m4 to facilitate local customization; the directory cf

of the sendmail distribution directory contains the source les. This directory contains several 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 (‘‘M4 Conguration’’) are

the input descriptions; the output is in the corresponding .cfle. The general

structure of these les 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 .mcle.

feature

Denitions of specic features that some particular host in your site might want.

These are referenced using the FEATURE m4 macro. An example feature is

use_cw_le (which tells sendmail to read an /etc/mail/local-host-names le on

startup to nd the set of local names).

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 les that have information common to all congu-

ration les. This can be thought of as a “#include” directory.

mailer

Denitions of mailers, referenced using the MAILER m4 macro. The mailer types

that are known in this distribution are fax, local, smtp, uucp, and usenet. For ex-

ample, to include support for the UUCP-based mailers, use “MAILER(uucp)”.

ostype

Denitions describing various operating system environments (such as the loca-

tion of support les). These are referenced using the OSTYPE m4 macro.

sh

Shellles used by the m4 build process. You shouldn’t hav e to mess with these.

sitecong

Local UUCP connectivity information. This directory has been supplanted by the

mailertable feature; any new congurations should use that feature to do UUCP

(and other) routing. The use of this directory is deprecated.

If you are in a new domain (e.g., a company), you will probably want to create a cf/domain

le for your domain. This consists primarily of relay denitions and features you want enabled site-

wide: for example, Berkeley’s domain denition denes relays for BitNET and UUCP. These are

specic to Berkeley, and should be fully-qualied internet-style domain names. Please check to

make certain they are reasonable for your domain.

Subdomains at Berkeley are also represented in the cf/domain directory. For example, the do-

main CS.Berkeley.EDU is the Computer Science subdomain, EECS.Berkeley.EDU is the Electrical

Engineering and Computer Sciences subdomain, and S2K.Berkeley.EDU is the Sequoia 2000 sub-

domain. You will probably have to add an entry to this directory to be appropriate for your domain.

You will have to use or create .mcles in the cf/cf subdirectory for your hosts. This is de-

tailed in the cf/README le.

1.3. Details of Installation Files

This subsection describes the les that comprise the sendmail installation.

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 set-group-ID smmsp as de-

scribed in sendmail/SECURITY. For security reasons, /, /usr, and /usr/sbin should be owned by

root, mode 07552.

1.3.2. /etc/mail/sendmail.cf

This is the main conguration le for sendmail3. This is one of the two non-library le

names compiled into sendmail4, the other is /etc/mail/submit.cf.

The conguration le is normally created using the distribution les described above. If

you have a particularly unusual system conguration you may need to create a special version.

The format of this le is detailed in later sections of this document.

1.3.3. /etc/mail/submit.cf

This is the conguration le for sendmail when it is used for initial mail submission, in

which case it is also called ‘‘Mail Submission Program’’ (MSP) in contrast to ‘‘Mail Transfer

Agent’’ (MTA). Starting with version 8.12, sendmail uses one of two different conguration

les based on its operation mode (or the newA option). For initial mail submission, i.e., if one

of the optionsbm (default),bs, ort is specied, submit.cf is used (if available), for other

operations sendmail.cf is used. Details can be found in sendmail/SECURITY. submit.cf is

shipped with sendmail (in cf/cf/) and is installed by default. If changes to the conguration need

to be made, start with cf/cf/submit.mc and follow the instruction in cf/README.

1.3.4. /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.5. /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.

Thevag will prevent the status display from being truncated. It functions only when the

HostStatusDirectory option is set.

1.3.6. /usr/bin/purgestat

This command is also a link to sendmail. Itushes expired (Timeout.hoststatus) informa-

tion that is stored in the HostStatusDirectory tree.

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

2Some 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.

3Actually, 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 le, add -D_PATH_SENDMAIL-

CF=\"/le/name\" to the ags passed to the C compiler. Moving this le is not recommended: other programs and scripts know of this

location.

4The system libraries can reference other les; in particular, system library subroutines that sendmail calls probably reference

/etc/passwd and /etc/resolv.conf.

Sendmail Installation and Operation Guide

SMM:08-11

1.3.7. /var/spool/mqueue

The directory /var/spool/mqueue should be created to hold the mail queue. This directory

should be mode 0700 and owned by root.

The actual path of this directory is dened by the QueueDirectory option of the send-

mail.cfle. 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 struc-

ture while sendmail is running.

If these directories have subdirectories or symbolic links to directories named ‘qf’, ‘df’,

and ‘xf’, then these will be used for the different queue le types. That is, the data les are

stored in the ‘df’ subdirectory, the transcript les are stored in the ‘xf’ subdirectory, and all oth-

ers are stored in the ‘qf’ subdirectory.

If shared memory support is compiled in, sendmail stores the available diskspace in a

shared memory segment to make the values readily available to all children without incurring

system overhead. In this case, only the daemon updates the data; i.e., the sendmail daemon cre-

ates the shared memory segment and deletes it if it is terminated. To use this, sendmail must

have been compiled with support for shared memory (-DSM_CONF_SHM) and the option

SharedMemoryKey must be set. Notice: do not use the same key for sendmail invocations

with different queue directories or different queue group declarations. Access to shared memory

is not controlled by locks, i.e., there is a race condition when data in the shared memory is up-

dated. However, since operation of sendmail does not rely on the data in the shared memory,

this does not negatively inuence the behavior.

1.3.8. /var/spool/clientmqueue

The directory /var/spool/clientmqueue should be created to hold the mail queue. This di-

rectory should be mode 0770 and owned by user smmsp, group smmsp.

The actual path of this directory is dened by the QueueDirectory option of the submit.cf

le.

1.3.9. /var/spool/mqueue/.hoststat

This is a typical value for the HostStatusDirectory option, containing one le per host

that this sendmail has chatted with recently. It is normally a subdirectory of mqueue.

1.3.10. /etc/mail/aliases*

The system aliases are held in “/etc/mail/aliases”. A sample is given in “sendmail/aliases”

which includes some aliases which must be dened:

cp sendmail/aliases /etc/mail/aliases

edit /etc/mail/aliases

You should extend this le with any aliases that are apropos to your system.

Normally sendmail looks at a database version of the les, stored either in

“/etc/mail/aliases.dir” and “/etc/mail/aliases.pag” or “/etc/mail/aliases.db” depending on which

database package you are using. The actual path of this le is dened in the AliasFile option of

the sendmail.cfle.

The permissions of the alias le and the database versions should be 0640 to prevent local

denial of service attacks as explained in the top level README in the sendmail distribution. If

the permissions 0640 are used, be sure that only trusted users belong to the group assigned to

those les. Otherwise, les should not even be group readable.

SMM:08-12

Sendmail Installation and Operation Guide

1.3.11. /etc/rc or /etc/init.d/sendmail

It will be necessary to start up the sendmail daemon when your system reboots. This dae-

mon performs two functions: it listens on the SMTP socket for connections (to receive mail

from a remote system) and it processes the queue periodically to insure that mail gets delivered

when hosts come up.

If necessary, add the following lines to “/etc/rc” (or “/etc/rc.local” as appropriate) in the

area where it is starting up the daemons on a BSD-base system, or on a System-V-based system

in one of the startup les, typically “/etc/init.d/sendmail”:

if [ f /usr/sbin/sendmail a f /etc/mail/sendmail.cf ]; then

(cd /var/spool/mqueue; rm f xf*)

/usr/sbin/sendmail bd q30m &

echo n ’ sendmail’ >/dev/console

The “cd” and “rm” commands insure that all transcript les have been removed; extraneous

transcript les may be left around if the system goes down in the middle of processing a mes-

sage. The line that actually invokes sendmail has twoags: “bd” causes it to listen on the

SMTP port, and “q30m” causes it to run the queue every half hour.

Some people use a more complex startup script, removing zero length qf/hf/Qf les and df

les for which there is no qf/hf/Qf le. Note this is not advisable. For example, see Figure 1 for

an example of a complex script which does this clean up.

1.3.12. /etc/mail/helple

This is the help le used by the SMTP HELP command. It should be copied from “send-

mail/helple”:

cp sendmail/helple /etc/mail/helple

The actual path of this le is dened in the HelpFile option of the sendmail.cfle.

1.3.13. /etc/mail/statistics

If you wish to collect statistics about your mail trafc, you should create the le

“/etc/mail/statistics”:

cp /dev/null /etc/mail/statistics

chmod 0600 /etc/mail/statistics

This le does not grow. It is printed with the program “mailstats/mailstats.c.” The actual path

of this le is dened in the S option of the sendmail.cfle.

1.3.14. /usr/bin/mailq

If sendmail is invoked as “mailq,” it will simulate thebpag (i.e., sendmail will print

the contents of the mail queue; see below). This should be a link to /usr/sbin/sendmail.

1.3.15. sendmail.pid

sendmail stores its current pid in the le specied by the PidFile option (default is

_PATH_SENDMAILPID). sendmail uses TempFileMode (which defaults to 0600) as the per-

missions of that le to prevent local denial of service attacks as explained in the top level

README in the sendmail distribution. If the le already exists, then it might be necessary to

change the permissions accordingly, e.g.,

chmod 0600 /var/run/sendmail.pid

Note that as of version 8.13, this le is unlinked when sendmail exits. As a result of this

change, a script such as the following, which may have worked prior to 8.13, will no longer

Sendmail Installation and Operation Guide

SMM:08-13

#!/bin/sh

# remove zero length qf/hf/Qf les

for qfle in qf* hf* Qf*

do

if [ r $qfle ]

then

if [ ! s $qfle ]

then

echo n " <zero: $qfle>" > /dev/console

rm f $qfle

done

# rename tf les to be qf if the qf does not exist

for tfle in tf*

do

qfle=‘echo $tfle | sed ’s/t/q/’‘

if [ r $tfle a ! f $qfle ]

then

echo n " <recovering: $tfle>" > /dev/console

mv $tfle $qfle

else

if [ f $tfle ]

then

echo n " <extra: $tfle>" > /dev/console

rm f $tfle

done

# remove dfles with no corresponding qf/hf/Qf les

for dfle in df*

do

qfle=‘echo $dfle | sed ’s/d/q/’‘

hfle=‘echo $dfle | sed ’s/d/h/’‘

Qfle=‘echo $dfle | sed ’s/d/Q/’‘

if [ r $dfle a ! f $qfle a ! f $hfle a ! f $Qfle ]

then

echo n " <incomplete: $dfle>" > /dev/console

mv $dfle ‘echo $dfle | sed ’s/d/D/’‘

done

# announce les that have been saved during disaster recovery

for xfle in [A-Z]f*

do

if [ f $xfle ]

then

echo n " <panic: $xfle>" > /dev/console

done

SMM:08-14

Sendmail Installation and Operation Guide

Figure 1 — A complex startup script

work:

# stop & start sendmail

PIDFILE=/var/run/sendmail.pid

kill ‘head -1 $PIDFILE‘

‘tail -1 $PIDFILE‘

because it assumes that the pidle will still exist even after killing the process to which it refers.

Below is a script which will work correctly on both newer and older versions:

# stop & start sendmail

PIDFILE=/var/run/sendmail.pid

pid=‘head -1 $PIDFILE‘

cmd=‘tail -1 $PIDFILE‘

kill $pid

$cmd

This is just an example script, it does not perform any error checks, e.g., whether the pidle ex-

ists at all.

1.3.16. Map Files

To prevent local denial of service attacks as explained in the top level README in the

sendmail distribution, the permissions of map les created by makemap should be 0640. The

use of 0640 implies that only trusted users belong to the group assigned to those les. If those

les already exist, then it might be necessary to change the permissions accordingly, e.g.,

cd /etc/mail

chmod 0640 *.db *.pag *.dir

2. NORMAL OPERATIONS

2.1. The System Log

The system log is supported by the syslogd (8) program. All messages from sendmail are

logged under the LOG_MAIL facility5.

2.1.1. Format

Each line in the system log consists of a timestamp, the name of the machine that 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 rst logs the

receipt of a message; there will be exactly one of these per message. Some elds 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.

5Except on Ultrix, which does not support facilities in the syslog.

6This format may vary slightly if your vendor has changed the syntax.

Sendmail Installation and Operation Guide

SMM:08-15

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

bodytype

The message body type (7BIT or 8BITMIME), as determined from the enve-

lope.

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:

to

A comma-separated list of the recipients to this mailer.

ctladdr

The ‘‘controlling user’’, that is, the name of the user whose credentials we use

for delivery.

delay

The total delay between the time this message was received and the current

delivery attempt.

xdelay

The amount of time needed in this delivery attempt (normally indicative of the

speed of the connection).

mailer

The name of the mailer used to deliver to this recipient.

relay

The name of the host that actually accepted (or rejected) this recipient.

dsn

The enhanced error code (RFC 2034) if available.

stat

The delivery status.

Not all elds are present in all messages; for example, the relay is usually not listed for local de-

liveries.

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 1164 are reserved for verbose information that some sites might want.

A complete description of the log levels is given in section ‘‘Log Level’’.

2.2. Dumping State

You can ask sendmail to log a dump of the open les and the connection cache by sending it a

SIGUSR1 signal. The results are logged at LOG_DEBUG priority.

2.3. The Mail Queues

Mail messages may either be delivered immediately or be held for later delivery. Held mes-

sages are placed into a holding directory called a mail queue.

A mail message may be queued for these reasons:

• If a mail message is temporarily undeliverable, it is queued and delivery is attempted later. If the

message is addressed to multiple recipients, it is queued only for those recipients to whom

SMM:08-16

Sendmail Installation and Operation Guide

delivery is not immediately possible.

• If the SuperSafe option is set to true, all mail messages are queued while delivery is attempted.

• If the DeliveryMode option is set to queue-only or defer, all mail is queued, and no immediate

delivery is attempted.

• If the load average becomes higher than the value of the QueueLA option and the QueueFactor

(q) option divided by the difference in the current load average and the QueueLA option plus

one is less than the priority of the message, messages are queued rather than immediately deliv-

ered.

• One or more addresses are marked as expensive and delivery is postponed until the next queue

run or one or more address are marked as held via mailer which uses the hold mailer ag.

• The mail message has been marked as quarantined via a mail lter or rulesets.

2.3.1. Queue Groups and Queue Directories

There are one or more mail queues. Each mail queue belongs to a queue group. There is

always a default queue group that is called ‘‘mqueue’’ (which is where messages go by default

unless otherwise specied). The directory or directories which comprise the default queue

group are specied by the QueueDirectory option. There are zero or more additional named

queue groups declared using the Q command in the conguration le.

By default, a queued message is placed in the queue group associated with the rst recipi-

ent in the recipient list. A recipient address is mapped to a queue group as follows. First, if

there is a ruleset called ‘‘queuegroup’’, and if this ruleset maps the address to a queue group

name, then that queue group is chosen. That is, the argument for the ruleset is the recipient ad-

dress (i.e., the address part of the resolved triple) and the result should be $# followed by the

name of a queue group. Otherwise, if the mailer associated with the address species a queue

group, then that queue group is chosen. Otherwise, the default queue group is chosen.

A message with multiple recipients will be split if different queue groups are chosen by

the mapping of recipients to queue groups.

When a message is placed in a queue group, and the queue group has more than one

queue, a queue is selected randomly.

If a message with multiple recipients is placed into a queue group with the ’r’ option

(maximum number of recipients per message) set to a positive value N, and if there are more

than N recipients in the message, then the message will be split into multiple messages, each of

which have at most N recipients.

Notice: if multiple queue groups are used, do not move queue les around, e.g., into a dif-

ferent queue directory. This may have weird effects and can cause mail not to be delivered.

Queue les and directories should be treated as opaque and should not be manipulated directly.

2.3.2. Queue Runs

sendmail has two different ways to process the queue(s). The rst one is to start queue

runners after certain intervals (‘‘normal’’ queue runners), the second one is to keep queue runner

processes around (‘‘persistent’’ queue runners). How to select either of these types is discussed

in the appendix ‘‘COMMAND LINE FLAGS’’. Persistent queue runners have the advantage

that no new processes need to be spawned at certain intervals; they just sleep for a specied time

after theynished a queue run. Another advantage of persistent queue runners is that only one

process belonging to a workgroup (a workgroup is a set of queue groups) collects the data for a

queue run and then multiple queue runner may go ahead using that data. This can signicantly

reduce the disk I/O necessary to read the queue les compared to starting multiple queue run-

ners directly. Their disadvantage is that a new queue run is only started after all queue runners

belonging to a group nished their tasks. In case one of the queue runners tries delivery to a

slow recipient site at the end of a queue run, the next queue run may be substantially delayed.

In general this should be smoothed out due to the distribution of those slow jobs, however, for

Sendmail Installation and Operation Guide

SMM:08-17

sites with small number of queue entries this might introduce noticeable delays. In general, per-

sistent queue runners are only useful for sites with big queues.

2.3.3. Manual Intervention

Under normal conditions the mail queue will be processed transparently. Howev er, you

may nd that manual intervention is sometimes necessary. For example, if a major host is down

for a period of time the queue may become clogged. Although sendmail ought to recover grace-

fully when the host comes up, you may nd performance unacceptably bad in the meantime. In

that case you want to check the content of the queue and manipulate it as explained in the next

two sections.

2.3.4. Printing the queue

The contents of the queue(s) can be printed using the mailq command (or by specifying

thebpag to sendmail):

mailq

This will produce a listing of the queue id’s, the size of the message, the date the message en-

tered the queue, and the sender and recipients. If shared memory support is compiled in, the

agbP can be used to print the number of entries in the queue(s), provided a process updates

the data. However, as explained earlier, the output might be slightly wrong, since access to the

shared memory is not locked. For example, ‘‘unknown number of entries’’ might be shown.

The internal counters are updated after each queue run to the correct value again.

2.3.5. Forcing the queue

Sendmail should run the queue automatically at intervals. When using multiple queues, a

separate process will by default be created to run each of the queues unless the queue run is ini-

tiated by a user with the verbose ag. The algorithm is to read and sort the queue, and then to

attempt to process all jobs in order. When it attempts to run the job, sendmailrst checks to see

if the job is locked. If so, it ignores the job.

There is no attempt to insure that only one queue processor exists at any time, since there

is no guarantee that a job cannot take forever to process (however, sendmail does include heuris-

tics to try to abort jobs that are taking absurd amounts of time; technically, this violates RFC

821, but is blessed by RFC 1123). Due to the locking algorithm, it is impossible for one job to

freeze the entire queue. However, an uncooperative recipient host or a program recipient that

never returns can accumulate many processes in your system. Unfortunately, there is no com-

pletely general way to solve this.

In some cases, you may nd that a major host going down for a couple of days may create

a prohibitively large queue. This will result in sendmail spending an inordinate amount of time

sorting the queue. This situation can be xed by moving the queue to a temporary place and

creating a new queue. The old queue can be run later when the offending host returns to service.

To do this, it is acceptable to move the entire queue directory:

cd /var/spool

mv mqueue omqueue; mkdir mqueue; chmod 0700 mqueue

You should then kill the existing daemon (since it will still be processing in the old queue direc-

tory) and create a new daemon.

To run the old mail queue, issue the following command:

/usr/sbin/sendmail C /etc/mail/queue.cf q

TheCag species an alternate conguration le queue.cf which should refer to the moved

queue directory

SMM:08-18

Sendmail Installation and Operation Guide

O QueueDirectory=/var/spool/omqueue

and theqag says to just run every job in the queue. You can also specify the moved queue

directory on the command line

/usr/sbin/sendmail oQ/var/spool/omqueue q

but this requires that you do not have queue groups in the conguration le, because those are

not subdirectories of the moved directory. See the section about ‘‘Queue Group Declaration’’

for details; you most likely need a different conguration le to correctly deal with this problem.

However, a proper conguration of queue groups should avoid lling up queue directories, so

you shouldn’t run into this problem. If you have a tendency tow ard voyeurism, you can use the

vag to watch what is going on.

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

rmdir /var/spool/omqueue

2.3.6. Quarantined Queue Items

It is possible to "quarantine" mail messages, otherwise known as envelopes. Envelopes

(queue les) are stored but not considered for delivery or display unless the "quarantine" state of

the envelope is undone or delivery or display of quarantined items is requested. Quarantined

messages are tagged by using a different name for the queue le, ’hf’ instead of ’qf’, and by

adding the quarantine reason to the queue le.

Delivery or display of quarantined items can be requested using theqQag to sendmail

or mailq. Additionally, messages already in the queue can be quarantined or unquarantined us-

ing the newQag to sendmail. For example,

sendmail -Qreason -q[!][I|R|S][matchstring]

Quarantines the normal queue items matching the criteria specied by the -q[!][I|R|S][match-

string] using the reason given on theQag. Likewise,

sendmail -qQ -Q[reason] -q[!][I|R|S|Q][matchstring]

Change the quarantine reason for the quarantined items matching the criteria specied by the

-q[!][I|R|S|Q][matchstring] using the reason given on theQag. If there is no reason,

unquarantine the matching items and make them normal queue items. Note that theqQag

tells sendmail to operate on quarantined items instead of normal items.

2.4. Disk Based Connection Information

Sendmail stores a large amount of information about each remote system it has connected to

in memory. It is possible to preserve some of this information on disk as well, by using the HostSta-

tusDirectory option, so that it may be shared between several invocations of sendmail. This allows

mail to be queued immediately or skipped during a queue run if there has been a recent failure in

connecting to a remote machine. Note: information about a remote system is stored in a le whose

pathname consists of the components of the hostname in reverse order. For example, the informa-

tion for host.example.com is stored in com./example./host. For top-level domains like com this

can create a large number of subdirectories which on some lesystems can exhaust some limits.

Moreover, the performance of lookups in directory with thousands of entries can be fairly slow de-

pending on the lesystem implementation.

Additionally enabling SingleThreadDelivery has the added effect of single-threading mail

delivery to a destination. This can be quite helpful if the remote machine is running an SMTP

server that is easily overloaded or cannot accept more than a single connection at a time, but can

cause some messages to be punted to a future queue run. It also applies to all hosts, so setting this

because you have one machine on site that runs some software that is easily overrun can cause mail

to other hosts to be slowed down. If this option is set, you probably want to set the MinQueueAge

Sendmail Installation and Operation Guide

SMM:08-19

option as well and run the queue fairly frequently; this way jobs that are skipped because another

sendmail is talking to the same host will be tried again quickly rather than being delayed for a long

time.

The disk based host information is stored in a subdirectory of the mqueue directory called

.hoststat7. Removing this directory and its subdirectories has an effect similar to the purgestat

command and is completely safe. However, purgestat only removes expired (Timeout.hoststatus)

data. The information in these directories can be perused with the hoststat command, which will in-

dicate 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 thebH switch. The connection information may be

viewed with the hoststat command or by invoking sendmail with thebh switch.

2.5. The Service Switch

The implementation of certain system services such as host and user name lookup is con-

trolled by the service switch. If the host operating system supports such a switch, and sendmail

knows about it, sendmail will use the native version. Ultrix, Solaris, and DEC OSF/1 are examples

of such systems8.

If the underlying operating system does not support a service switch (e.g., SunOS 4.X, HP-

UX, BSD) then sendmail will provide a stub implementation. The ServiceSwitchFile option points

to the name of a le that has the service denitions. Each line has the name of a service and the

possible implementations of that service. For example, the le:

hosts

dnsles nis

aliases les nis

will ask sendmail to look for hosts in the Domain Name System rst. If the requested host name is

not found, it tries local les, and if that fails it tries NIS. Similarly, when looking for aliases it will

try the local les rst followed by NIS.

Notice: since sendmail must access MX records for correct operation, it will use DNS if it is

congured in the ServiceSwitchFilele. Hence an entry like

hosts

les dns

will not avoid DNS lookups even if a host can be found in /etc/hosts.

Note: in contrast to the sendmail stub implementation some operating systems do not preserve

temporary failures. For example, if DNS returns a TRY_AGAIN status for this setup

hosts

les dns myhostname

but myhostname does not nd the requested entry, then a permanent error is returned to sendmail

which obviously can cause problems, e.g., an immediate bounce instead of a deferral.

Service switches are not completely integrated. For example, despite the fact that the host en-

try listed in the above example species to look in NIS, on SunOS this won’t happen because the

system implementation of gethostbyname (3) doesn’t understand this.

7This is the usual value of the HostStatusDirectory option; it can, of course, go anywhere you like in your lesystem.

8HP-UX 10 has service switch support, but since the APIs are apparently not available in the libraries sendmail does not use the

native service switch in this release.

SMM:08-20

Sendmail Installation and Operation Guide

2.6. The Alias Database

After recipient addresses are read from the SMTP connection or command line they are

parsed by ruleset 0, which must resolve to a {mailer, host, address} triple. If the ags selected by

the mailer include the A (aliasable) ag, the address part of the triple is looked up as the key (i.e.,

the left hand side) in the alias database. If there is a match, the address is deleted from the send

queue and all addresses on the right hand side of the alias are added in place of the alias that was

found. This is a recursive operation, so aliases found in the right hand side of the alias are similarly

expanded.

The alias database exists in two forms. One is a text form, maintained in the le

/etc/mail/aliases. The aliases are of the form

name: name1, name2, ...

Only local names may be aliased; e.g.,

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

will not have the desired effect (except on prep.ai.MIT.EDU, and they probably don’t want me)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 one of the available map types, e.g., ndbm (3)10 the Berkeley

DB library, or cdb. This is the form that sendmail actually uses to resolve aliases. This technique is

used to improve performance.

The control of search order is actually set by the service switch. Essentially, the entry

O AliasFile=switch:aliases

is always added as the rst alias entry; also, the rst alias le name without a class (e.g., without

“nis:” on the front) will be used as the name of the le for a ‘‘les’’ entry in the aliases switch. For

example, if the conguration le contains

O AliasFile=/etc/mail/aliases

and the service switch contains

aliases nisles nisplus

then aliases will rst be searched in the NIS database, then in /etc/mail/aliases, then in the NIS+

database.

You can also use NIS-based alias les. For example, the specication:

O AliasFile=/etc/mail/aliases

O AliasFile=nis:mail.aliases@my.nis.domain

will rst search the /etc/mail/aliases le and then the map named “mail.aliases” in “my.nis.domain”.

Warning: if you build your own NIS-based alias les, be sure to provide thelag 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 ags can be added after the colon exactly like a K line — for example:

O AliasFile=nis:N mail.aliases@my.nis.domain

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

9Actually, any mailer that has the ‘A’ mailer ag set will permit aliasing; this is normally limited to the local mailer.

10The gdbm package does not work.

Sendmail Installation and Operation Guide

SMM:08-21

O AliasFile=nis:f mail.aliases@my.nis.domain

will prevent sendmail from downcasing the key before the alias lookup.

2.6.1. Rebuilding the alias database

The hash or dbm version of the database may be rebuilt explicitly by executing the com-

mand

newaliases

This is equivalent to giving sendmail thebiag:

/usr/sbin/sendmail bi

If you have multiple aliases databases specied, thebiag rebuilds all the database

types it understands (for example, it can rebuild NDBM databases but not NIS databases).

2.6.2. Potential problems

There are a number of problems that can occur with the alias database. They all result

from a sendmail process accessing the DBM version while it is only partially built. This can

happen under two circumstances: One process accesses the database while another process is re-

building it, or the process rebuilding the database dies (due to being killed or a system crash) be-

fore completing the rebuild.

Sendmail has three techniques to try to relieve these problems. First, it ignores interrupts

while rebuilding the database; this avoids the problem of someone aborting the process leaving a

partially rebuilt database. Second, it locks the database source le during the rebuild — but that

may not work over NFS or if the le is unwritable. Third, at the end of the rebuild it adds an

alias of the form

@: @

(which is not normally legal). Before sendmail will access the database, it checks to insure that

this entry exists11.

2.6.3. List owners

If an error occurs on sending to a certain address, say “x”, sendmail will look for an alias

of the form “owner-x” to receive the errors. This is typically useful for a mailing list where the

submitter of the list has no control over the maintenance of the list itself; in this case the list

maintainer would be the owner of the list. For example:

unix-wizards: eric@ucbarpa, wnj@monet, nosuchuser,

sam@matisse

owner-unix-wizards: unix-wizards-request

unix-wizards-request: eric@ucbarpa

would cause “eric@ucbarpa” to get the error that will occur when someone sends to unix-wiz-

ards due to the inclusion of “nosuchuser” on the list.

List owners also cause the envelope sender address to be modied. The contents of the

owner alias are used if they point to a single user, otherwise the name of the alias itself is used.

For this reason, and to obey Internet conventions, the “owner-” address normally points at the

“-request” address; this causes messages to go out with the typical Internet convention of using

‘‘list-request’’ as the return address.

11The AliasWait option is required in the conguration for this action to occur. This should normally be specied.

SMM:08-22

Sendmail Installation and Operation Guide

2.7. User Information Database

This option is deprecated, use virtusertable and genericstable instead as explained in

cf/README. If you have a version of sendmail with the user information database compiled in, and

you have specied one or more databases using the U option, the databases will be searched for a

user:maildrop entry. If found, the mail will be sent to the specied address.

2.8. Per-User Forwarding (.forward Files)

As an alternative to the alias database, any user may put a le with the name “.forward” in his

or her home directory. If this le exists, sendmail redirects mail for that user to the list of addresses

listed in the .forward le. Note that aliases are fully expanded before forward les are referenced.

For example, if the home directory for user “mckusick” has a .forward le with contents:

mckusick@ernie

kirk@calder

then any mail arriving for “mckusick” will be redirected to the specied accounts.

Actually, the conguration le denes a sequence of lenames to check. By default, this is

the user’s .forward le, but can be dened to be more generally using the ForwardPath option. If

you change this, you will have to inform your user base of the change; .forward is pretty well incor-

porated into the collective subconscious.

2.9. Special Header Lines

Several header lines have special interpretations dened by the conguration le. Others

have interpretations built into sendmail that cannot be changed without changing the code. These

built-ins are described here.

2.9.1. Errors-To:

If errors occur anywhere during processing, this header will cause error messages to go to

the listed addresses. This is intended for mailing lists.

The Errors-To: header was created in the bad old days when UUCP 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 ofcially deprecated and will go away in a future release.

2.9.2. Apparently-To:

RFC 822 requires at least one recipient eld (To:, Cc:, or Bcc: line) in every message. If a

message comes in with no recipients listed in the message then sendmail will adjust the header

based on the “NoRecipientAction” option. One of the possible actions is to add an “Apparently-

To:” header line for any recipients it is aware of.

The Apparently-To: header is non-standard and is both deprecated and strongly discour-

aged.

2.9.3. Precedence

The Precedence: header can be used as a crude control of message priority. It tweaks the

sort order in the queue and can be congured to change the message timeout values. The prece-

dence of a message also controls how delivery status notications (DSNs) are processed for that

message.

Sendmail Installation and Operation Guide

SMM:08-23

2.10. IDENT Protocol Support

Sendmail supports the IDENT protocol as dened in RFC 1413. Note that the RFC states a

client should wait at least 30 seconds for a response. The default Timeout.ident is 5 seconds as

many sites have adopted the practice of dropping IDENT queries. This has lead to delays process-

ing mail. Although this enhances identication of the author of an email message by doing a ‘‘call

back’’ to the originating system to include the owner of a particular TCP connection in the audit

trail it is in no sense perfect; a determined forger can easily spoof the IDENT protocol. The follow-

ing description is excerpted from RFC 1413:

6. Security Considerations

The information returned by this protocol is at most as trustworthy as the host providing it OR

the organization operating the host. For example, a PC in an open lab has few if any controls

on it to prevent a user from having this protocol return any identier the user wants. Like-

wise, if the host has been compromised the information returned may be completely erro-

neous and misleading.

The Identication Protocol is not intended as an authorization or access control protocol. At

best, it provides some additional auditing information with respect to TCP connections. At

worst, it can provide misleading, incorrect, or maliciously incorrect information.

The use of the information returned by this protocol for other than auditing is strongly dis-

couraged. Specically, using Identication 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 Identication server may reveal information about users, entities, objects or processes

which might normally be considered private. An Identication server provides service which

is a rough analog of the CallerID services provided by some phone companies and many of

the same privacy considerations and arguments that apply to the CallerID service apply to

Identication. If you wouldn’t run a "nger" server due to privacy considerations you may

not want to run this protocol.

In some cases your system may not work properly with IDENT support due to a bug in the TCP/IP

implementation. The symptoms will be that for some hosts the SMTP connection will be closed al-

most immediately. If this is true or if you do not want to use IDENT, you should set the IDENT

timeout to zero; this will disable the IDENT protocol.

3. ARGUMENTS

The complete list of arguments to sendmail is described in detail in Appendix A. Some important

arguments are described here.

3.1. Queue Interval

The amount of time between forking a process to run through the queue is dened by theq

ag. If you run with delivery mode set to i or b this can be relatively large, since it will only be rel-

evant when a host that was down comes back up. If you run in q mode it should be relatively short,

since it denes the maximum amount of time that a message may sit in the queue. (See also the

MinQueueAge option.)

RFC 1123 section 5.3.1.1 says that this value should be at least 30 minutes (although that

probably doesn’t make sense if you use ‘‘queue-only’’ mode).

Notice: the meaning of the interval time depends on whether normal queue runners or persis-

tent queue runners are used. For the former, it is the time between subsequent starts of a queue run.

For the latter, it is the time sendmail waits after a persistent queue runner has nished its work to

start the next one. Hence for persistent queue runners this interval should be very low, typically no

more than two minutes.

SMM:08-24

Sendmail Installation and Operation Guide

3.2. Daemon Mode

If you allow incoming mail over an IPC connection, you should have a daemon running. This

should be set by your /etc/rcle using thebdag. Thebdag and theqag may be combined

in one call:

/usr/sbin/sendmail bd q30m

An alternative approach is to invoke sendmail from inetd(8) (use thebsAm ags to ask

sendmail to speak SMTP on its standard input and output and to run as MTA). This works and al-

lows you to wrap sendmail in a TCP wrapper program, but may be a bit slower since the congura-

tion le has to be re-read on every message that comes in. If you do this, you still need to have a

sendmail running to ush the queue:

/usr/sbin/sendmail q30m

3.3. Forcing the Queue

In some cases you may nd that the queue has gotten clogged for some reason. You can force

a queue run using theqag (with no value). It is entertaining to use thevag (verbose) when

this is done to watch what happens:

/usr/sbin/sendmail q v

You can also limit the jobs to those with a particular queue identier, recipient, sender, quar-

antine reason, or queue group using one of the queue modiers. For example, “qRberkeley” re-

stricts the queue run to jobs that have the string “berkeley” somewhere in one of the recipient ad-

dresses. Similarly, “qSstring” limits the run to particular senders, “qIstring” limits it to particular

queue identiers, and “qQstring” limits it to particular quarantined reasons and only operated on

quarantined queue items, and “qGstring” limits it to a particular queue group. The named queue

group will be run even if it is set to have 0 runners. You may also place an ! before the I or R or S

or Q to indicate that jobs are limited to not including a particular queue identier, recipient or

sender. For example, “q!Rseattle” limits the queue run to jobs that do not have the string “seattle”

somewhere in one of the recipient addresses. Should you need to terminate the queue jobs currently

active then a SIGTERM to the parent of the process (or processes) will cleanly stop the jobs.

3.4. Debugging

There are a fairly large number of debug ags built into sendmail. Each debug ag has a cat-

egory and a level. Higher levels increase the level of debugging activity; in most cases, this 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.

You should never run a production sendmail server in debug mode. Many of the debug ags

will result in debug output being sent over the SMTP channel unless the optionD is used. This

will confuse many mail programs. However, for testing purposes, it can be useful when sending

mail manually via telnet to the port you are using while debugging.

A debug category is either an integer, like 42, or a name, like ANSI. You can specify a range

of numeric debug categories using the syntax 17-42. You can specify a set of named debug cate-

gories using a glob pattern like “sm_trace_*”. At present, only “*” and “?” are supported in these

glob patterns.

Debug ags are set using thed option; the syntax is:

Sendmail Installation and Operation Guide

SMM:08-25

debug-ag:

d debug-list

debug-list:

debug-option [ , debug-option ]*

debug-option:

debug-categories [ . debug-level ]

debug-categories:

integer | integer integer | category-pattern

category-pattern:

[a-zA-Z_*?][a-zA-Z0-9_*?]*

debug-level:

integer

where spaces are for reading ease only. For example,

d12

Set category 12 to level 1

d12.3

Set category 12 to level 3

d317

Set categories 3 through 17 to level 1

d317.4

Set categories 3 through 17 to level 4

dANSI

Set category ANSI to level 1

dsm_trace_*.3

Set all named categories matching sm_trace_* to level 3

For a complete list of the available debug ags you will have to look at the code and the TRACE-

FLAGSle in the sendmail distribution (they are too dynamic to keep this document up to date).

For a list of named debug categories in the sendmail binary, use

ident /usr/sbin/sendmail | grep Debug

3.5. Changing the Values of Options

Options can be overridden using theo orO command line ags. For example,

/usr/sbin/sendmail oT2m

sets the T (timeout) option to two minutes for this run only; the equivalent line using the long option

name is

/usr/sbin/sendmail -OTimeout.queuereturn=2m

Some options have security implications. Sendmail allows you to set these, but relinquishes

its set-user-ID or set-group-ID permissions thereafter12.

3.6. Trying a Different Conguration File

An alternative conguration le can be specied using theCag; for example,

/usr/sbin/sendmail Ctest.cf oQ/tmp/mqueue

uses the conguration le test.cf instead of the default /etc/mail/sendmail.cf. If theCag has no

value it defaults to sendmail.cf in the current directory.

Sendmail gives up set-user-ID root permissions (if it has been installed set-user-ID root) when

you use this ag, so it is common to use a publicly writable directory (such as /tmp) as the queue di-

rectory (QueueDirectory or Q option) while testing.

3.7. Logging Trafc

Many SMTP implementations do not fully implement the protocol. For example, some per-

sonal computer based SMTPs do not understand continuation lines in reply codes. These can be

very hard to trace. If you suspect such a problem, you can set trafc logging using theXag. For

example,

12That is, it sets its effective uid to the real uid; thus, if you are executing as root, as from root’s crontab le or during system

startup the root permissions will still be honored.

SMM:08-26

Sendmail Installation and Operation Guide

/usr/sbin/sendmail X /tmp/trafc bd

will log all trafc in the le /tmp/trafc.

This logs a lot of data very quickly and should NEVER be used during normal operations.

After starting up such a daemon, force the errant implementation to send a message to your host.

All message trafc in and out of sendmail, including the incoming SMTP trafc, will be logged in

this le.

3.8. Testing Conguration Files

When you build a conguration table, you can do a certain amount of testing using the “test

mode” of sendmail. For example, you could invoke sendmail as:

sendmail bt Ctest.cf

which would read the conguration le “test.cf” and enter test mode. In this mode, you enter lines

of the form:

rwset address

where rwset is the rewriting set you want to use and address is an address to apply the set to. Test

mode shows you the steps it takes as it proceeds, nally showing you the address it ends up with.

You may use a comma separated list of rwsets for sequential application of rules to an input. For

example:

3,1,21,4 monet:bollard

rst applies ruleset three to the input “monet:bollard.” Ruleset one is then applied to the output of

ruleset three, followed similarly by rulesets twenty-one and four.

If you need more detail, you can also use the “d21” ag to turn on more debugging. For ex-

ample,

sendmail bt d21.99

turns on an incredible amount of information; a single word address is probably going to print out

several pages worth of information.

You should be warned that internally, sendmail applies ruleset 3 to all addresses. In test mode

you will have to do that manually. For example, older versions allowed you to use

0 bruce@broadcast.sony.com

This version requires that you use:

3,0 bruce@broadcast.sony.com

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

.D x value

denes macro x to have the indicated value. This is useful when debugging rules

that use the $&x syntax.

.C c value

adds the indicated value to class c.

=S ruleset

dumps the contents of the indicated ruleset.

d debug-spec

is equivalent to the command-line ag.

Version 8.9 introduced more features:

?

shows a help message.

=M

display the known mailers.

$m

print the value of macro m.

$=c

print the contents of class c.

Sendmail Installation and Operation Guide

SMM:08-27

/mx host

returns the MX records for ‘host’.

/parse address

parse address, returning the value of crackaddr, and the parsed address.

/try mailer addr

rewrite address into the form it will have when presented to the indicated mailer.

/tryags ags

set ags used by parsing. The ags can be ‘H’ for Header or ‘E’ for Envelope,

and ‘S’ for Sender or ‘R’ for Recipient. These can be combined, ‘HR’ sets ags

for header recipients.

/canon hostname try to canonify hostname.

/map mapname key

look up ‘key’ in the indicated ‘mapname’.

/quit

quit address test mode.

3.9. Persistent Host Status Information

When HostStatusDirectory is enabled, information about the status of hosts is maintained on

disk and can thus be shared between different instantiations of sendmail. The status of the last con-

nection with each remote host may be viewed with the command:

sendmail bh

This information may be ushed with the command:

sendmail bH

Flushing the information prevents new sendmail processes from loading it, but does not prevent ex-

isting processes from using the status information that they already have.

4. TUNING

There are a number of conguration parameters you may want to change, depending on the re-

quirements of your site. Most of these are set using an option in the conguration le. For example,

the line “O Timeout.queuereturn=5d” sets option “Timeout.queuereturn” to the value “5d” (ve days).

Most of these options have appropriate defaults for most sites. However, sites having very high

mail loads may nd they need to tune them as appropriate for their mail load. In particular, sites experi-

encing a large number of small messages, many of which are delivered to many recipients, may nd

that they need to adjust the parameters dealing with queue priorities.

All versions of sendmail prior to 8.7 had single character option names. As of 8.7, options have

long (multi-character names). Although old short names are still accepted, most new options do not

have short equivalents.

This section only describes the options you are most likely to want to tweak; read section 5 for

more details.

4.1. Timeouts

All time intervals are set using a scaled syntax. For example, “10m” represents ten minutes,

whereas “2h30m” represents two and a half hours. The full set of scales is:

s

seconds

m

minutes

h

hours

d

days

w

weeks

4.1.1. Queue interval

The argument to theqag species how often a sub-daemon will run the queue. This is

typically set to between fteen minutes and one hour. If not set, or set to zero, the queue will

SMM:08-28

Sendmail Installation and Operation Guide

not be run automatically. RFC 1123 section 5.3.1.1 recommends that this be at least 30 minutes.

Should you need to terminate the queue jobs currently active then a SIGTERM to the parent of

the process (or processes) will cleanly stop the jobs.

4.1.2. Read timeouts

Timeouts all have option names “Timeout.suboption”. Most of these control SMTP oper-

ations. The recognized suboptions, their default values, and the minimum values allowed by

RFC 2821 section 4.5.3.2 (or RFC 1123 section 5.3.2) are:

connect

The time to wait for an SMTP connection to open (the connect(2) system call)

[0, unspecied]. If zero, uses the kernel default. In no case can this option

extend the timeout longer than the kernel provides, but it can shorten it. This

is to get around kernels that provide an absurdly long connection timeout (90

minutes in one case).

iconnect

The same as connect, except it applies only to the initial attempt to connect to

a host for a given message [0, unspecied]. The concept is that this should be

very short (a few seconds); hosts that are well connected and responsive will

thus be serviced immediately. Hosts that are slow will not hold up other deliv-

eries in the initial delivery attempt.

aconnect

[0, unspecied] The overall timeout waiting for all connection for a single de-

livery attempt to succeed. If 0, no overall limit is applied. This can be used to

restrict the total amount of time trying to connect to a long list of host that

could accept an e-mail for the recipient. This timeout does not apply to Fall-

backMXhost, i.e., if the time is exhausted, the FallbackMXhost is tried next.

initial

The wait for the initial 220 greeting message [5m, 5m].

helo

The wait for a reply from a HELO or EHLO command [5m, unspecied].

This may require a host name lookup, so ve minutes is probably a reasonable

minimum.

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 be-

low).

datainit†

The wait for a reply from a DAT A 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.

datanal†

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, unspecied].

quit

The wait for a reply from a QUIT command [2m, unspecied].

misc

The wait for a reply from miscellaneous (but short) commands such as NOOP

(no-operation) and VERB (go into verbose mode). [2m, unspecied].

command†‡

In server SMTP, the time to wait for another command. [1h, 5m].

ident‡

The timeout waiting for a reply to an IDENT query [5s13, unspecied].

13On some systems the default is zero to turn the protocol off entirely.

Sendmail Installation and Operation Guide

SMM:08-29

lhlo

The wait for a reply to an LMTP LHLO command [2m, unspecied].

auth

The timeout for a reply in an SMTP AUTH dialogue [10m, unspecied].

starttls

The timeout for a reply to an SMTP STARTTLS command and the TLS hand-

shake [1h, unspecied].

leopen‡

The timeout for opening .forward and :include: les [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 be-

fore it is considered stale [30m, unspecied].

resolver.retrans‡ The resolver’s retransmission time interval (in seconds) [varies]. Sets both

Timeout.resolver.retrans.rst and Timeout.resolver.retrans.normal.

resolver.retrans.rst‡

The resolver’s retransmission time interval (in seconds) for the rst attempt to

deliver a message [varies].

resolver.retrans.normal‡

The resolver’s retransmission time interval (in seconds) for all resolver

lookups except the rst delivery attempt [varies].

resolver.retry‡

The number of times to retransmit a resolver query. Sets both Timeout.re-

solver.retry.rst and Timeout.resolver.retry.normal [varies].

resolver.retry.rst‡

The number of times to retransmit a resolver query for the rst attempt to de-

liver a message [varies].

resolver.retry.normal‡

The number of times to retransmit a resolver query for all resolver lookups

except the rst delivery attempt [varies].

For compatibility with old conguration les, if no suboption is specied, all the timeouts

marked with a dagger (†) are set to the indicated value. All but those marked with a double dag-

ger (‡) apply to client SMTP.

For example, the lines:

O Timeout.command=25m

O Timeout.datablock=3h

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

hours.

4.1.3. Message timeouts

After sitting in the queue for a few days, an undeliverable message will time out. This is

to insure that at least the sender is aware of the inability to send a message. The timeout is typi-

cally set to ve days. It is sometimes considered convenient to also send a warning message if

the message is in the queue longer than a few hours (assuming you normally have good connec-

tivity; if your messages normally took several hours to send you wouldn’t want to do this be-

cause it wouldn’t be an unusual event). These timeouts are set using the Timeout.queuereturn

and Timeout.queuewarn options in the conguration le (previously both were set using the T

option).

If the message is submitted using the NOTIFY SMTP extension, warning messages will

only be sent if NOTIFY=DELAY is specied. The queuereturn and queuewarn timeouts can be

further qualied with a tag based on the Precedence: eld in the message; they must be one of

“urgent” (indicating a positive non-zero precedence), “normal” (indicating a zero precedence),

or

“non-urgent”

(indicating

negative

precedences).

For

example,

setting

SMM:08-30

Sendmail Installation and Operation Guide

“Timeout.queuewarn.urgent=1h” sets the warning timeout for urgent messages only to one hour.

The default if no precedence is indicated is to set the timeout for all precedences. If the message

has a normal (default) precedence and it is a delivery status notication (DSN), Time-

out.queuereturn.dsn and Timeout.queuewarn.dsn can be used to give an alternative warn and

return time for DSNs. The value "now" can be used for -O Timeout.queuereturn to return en-

tries immediately during a queue run, e.g., to bounce messages independent of their time in the

queue.

Since these options are global, and since you cannot know a priori how long another host

outside your domain will be down, a ve day timeout is recommended. This allows a recipient

to x the problem even if it occurs at the beginning of a long weekend. RFC 1123 section

5.3.1.1 says that this parameter should be ‘‘at least 45 days’’.

The Timeout.queuewarn value can be piggybacked on the T option by indicating a time

after which a warning message should be sent; the two timeouts are separated by a slash. For

example, the line

OT5d/4h

causes email to fail after ve days, but a warning message will be sent after four hours. This

should be large enough that the message will have been tried several times.

4.2. Forking During Queue Runs

By setting the ForkEachJob (Y) option, sendmail will fork before each individual message

while running the queue. This option was used with earlier releases to prevent sendmail from con-

suming large amounts of memory. It should no longer be necessary with sendmail 8.12. If the

ForkEachJob option is not set, sendmail will keep track of hosts that are down during a queue run,

which can improve performance dramatically.

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

4.3. Queue Priorities

Every message is assigned a priority when it is rst instantiated, consisting of the message

size (in bytes) offset by the message class (which is determined from the Precedence: header) times

the “work class factor” and the number of recipients times the “work recipient factor.” The priority

is used to order the queue. Higher numbers for the priority mean that the message will be processed

later when running the queue.

The message size is included so that large messages are penalized relative to small messages.

The message class allows users to send “high priority” messages by including a “Precedence:” eld

in their message; the value of this eld is looked up in the P lines of the conguration le. Since the

number of recipients affects the amount of load a message presents to the system, this is also in-

cluded into the priority.

The recipient and class factors can be set in the conguration le using the RecipientFactor

(y) and ClassFactor (z) options respectively. They default to 30000 (for the recipient factor) and

1800 (for the class factor). The initial priority is:

pri = msgsize (class × ClassFactor) + (nrcpt × RecipientFactor)

(Remember, higher values for this parameter actually mean that the job will be treated with lower

priority.)

The priority of a job can also be adjusted each time it is processed (that is, each time an at-

tempt is made to deliver it) using the “work time factor,” set by the RetryFactor (Z) option. This is

added to the priority, so it normally decreases the precedence of the job, on the grounds that jobs

that have failed many times will tend to fail again in the future. The RetryFactor option defaults to

90000.

Sendmail Installation and Operation Guide

SMM:08-31

4.4. Load Limiting

Sendmail can be asked to queue (but not deliver) mail if the system load average gets too high

using the QueueLA (x) option. When the load average exceeds the value of the QueueLA option,

the delivery mode is set to q (queue only) if the QueueFactor (q) option divided by the difference

in the current load average and the QueueLA option plus one is less than the priority of the message

— that is, the message is queued iff:

pri >

QueueFactor

LA QueueLA + 1

The QueueFactor option defaults to 600000, so each point of load average is worth 600000 priority

points (as described above).

For drastic cases, the RefuseLA (X) option denes a load average at which sendmail will

refuse to accept network connections. Locally generated mail, i.e., mail which is not submitted via

SMTP (including incoming UUCP mail), is still accepted. Notice that the MSP submits mail to the

MTA via SMTP, and hence mail will be queued in the client queue in such a case. Therefore it is

necessary to run the client mail queue periodically.

4.5. Resource Limits

Sendmail has several parameters to control resource usage. Besides those mentioned in the

previous

section,

there

are

at

least

MaxDaemonChildren,

ConnectionRateThrottle,

MaxQueueChildren, and MaxRunnersPerQueue. The latter two limit the number of sendmail

processes that operate on the queue. These are discussed in the section ‘‘Queue Group Declara-

tion’’. The former two can be used to limit the number of incoming connections. Their appropriate

values depend on the host operating system and the hardware, e.g., amount of memory. In many sit-

uations it might be useful to set limits to prevent to have too many sendmail processes, however,

these limits can be abused to mount a denial of service attack. For example, if MaxDaemonChil-

dren=10 then an attacker needs to open only 10 SMTP sessions to the server, leave them idle for

most of the time, and no more connections will be accepted. If this option is set then the timeouts

used in a SMTP session should be lowered from their default values to their minimum values as

specied in RFC 2821 and listed in section 4.1.2.

4.6. Measures against Denial of Service Attacks

Sendmail has some built-in measures against simple denial of service (DoS) attacks. The

SMTP server by default slows down if too many bad commands are issued or if some commands

are repeated too often within a session. Details can be found in the source le sendmail/srvrsmtp.c

by looking for the macro denitions of MAXBADCOMMANDS, MAXNOOPCOMMANDS,

MAXHELOCOMMANDS, MAXVRFYCOMMANDS, and MAXETRNCOMMANDS. If an

SMTP command is issued more often than the corresponding MAXcmdCOMMANDS value, then

the response is delayed exponentially, starting with a sleep time of one second, up to a maximum of

four minutes (as dened by MAXTIMEOUT). If the option MaxDaemonChildren is set to a

value greater than zero, then this could make a DoS attack even worse since it keeps a connection

open longer than necessary. Therefore a connection is terminated with a 421 SMTP reply code if

the number of commands exceeds the limit by a factor of two and MAXBADCOMMANDS is set

to a value greater than zero (the default is 25).

4.7. Delivery Mode

There are a number of delivery modes that sendmail can operate in, set by the DeliveryMode

(d) conguration option. These modes specify how quickly mail will be delivered. Legal modes

are:

SMM:08-32

Sendmail Installation and Operation Guide

i

deliver interactively (synchronously)

b

deliver in background (asynchronously)

q

queue only (don’t deliver)

d

defer delivery attempts (don’t deliver)

There are tradeoffs. Mode “i” gives the sender the quickest feedback, but may slow down some

mailers and is hardly ever necessary. Mode “b” delivers promptly but can cause large numbers of

processes if you have a mailer that takes a long time to deliver a message. Mode “q” minimizes the

load on your machine, but means that delivery may be delayed for up to the queue interval. Mode

“d” is identical to mode “q” except that it also prevents lookups in maps including the -Dag from

working during the initial queue phase; it is intended for ‘‘dial on demand’’ sites where DNS

lookups might cost real money. Some simple error messages (e.g., host unknown during the SMTP

protocol) will be delayed using this mode. Mode “b” is the usual default.

If you run in mode “q” (queue only), “d” (defer), or “b” (deliver in background) sendmail will

not expand aliases and follow .forward les upon initial receipt of the mail. This speeds up the re-

sponse to RCPT commands. Mode “i” should not be used by the SMTP server.

4.8. Log Level

The level of logging can be set for sendmail. The default using a standard conguration is

level 9. The levels are approximately as follows (some log types are using different level depending

on various factors):

0

Minimal logging.

1

Serious system failures and potential security problems.

2

Lost communications (network problems) and protocol failures.

3

Other serious failures, malformed addresses, transient forward/include errors, connection

timeouts.

4

Minor failures, out of date alias databases, connection rejections via check_ rulesets.

5

Message collection statistics.

6

Creation of error messages, VRFY and EXPN commands.

7

Delivery failures (host or user unknown, etc.).

8

Successful deliveries and alias database rebuilds.

9

Messages being deferred (due to a host being down, etc.).

10

Database expansion (alias, forward, and userdb lookups) and authentication information.

11

NIS errors and end of job processing.

12

Logs all SMTP connections.

13

Log bad user shells, les with improper permissions, and other questionable situations.

14

Logs refused connections.

15

Log all incoming SMTP commands.

20

Logs attempts to run locked queue les. These are not errors, but can be useful to note if

your queue appears to be clogged.

30

Lost locks (only if using lockf instead of ock).

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

would ever set these.

Sendmail Installation and Operation Guide

SMM:08-33

4.9. File Modes

The modes used for les depend on what functionality you want and the level of security you

require. In many cases sendmail does careful checking of the modes of les and directories to avoid

accidental compromise; if you want to make it possible to have group-writable support les you

may need to use the DontBlameSendmail option to turn off some of these checks.

4.9.1. To suid or not to suid?

Sendmail is no longer installed set-user-ID to root. sendmail/SECURITY explains how to

congure and install sendmail without set-user-ID to root but set-group-ID which is the default

conguration starting with 8.12.

The daemon usually runs as root, unless other measures are taken. At the point where

sendmail is about to exec (2) a mailer, it checks to see if the userid is zero (root); if so, it resets

the userid and groupid to a default (set by the U= equate in the mailer line; if that is not set, the

DefaultUser option is used). This can be overridden by setting the Sag to the mailer for mail-

ers that are trusted and must be called as root. However, this will cause mail processing to be

accounted (using sa (8)) to root rather than to the user sending the mail.

A middle ground is to set the RunAsUser option. This causes sendmail to become the in-

dicated user as soon as it has done the startup that requires root privileges (primarily, opening

the SMTP socket). If you use RunAsUser, the queue directory (normally /var/spool/mqueue)

should be owned by that user, and all les and databases (including user .forwardles, alias

les, :include: les, and external databases) must be readable by that user. Also, since sendmail

will not be able to change its uid, delivery to programs or les will be marked as unsafe, e.g.,

undeliverable, in .forward, aliases, and :include: les. Administrators can override this by set-

ting the DontBlameSendmail option to the setting NonRootSafeAddr. RunAsUser is proba-

bly best suited for rewall congurations that don’t hav e regular user logins. If the option is

used on a system which performs local delivery, then the local delivery agent must have the

proper permissions (i.e., usually set-user-ID root) since it will be invoked by the RunAsUser,

not by root.

4.9.2. Turning off security checks

Sendmail is very particular about the modes of les that it reads or writes. For example,

by default it will refuse to read most les that are group writable on the grounds that they might

have been tampered with by someone other than the owner; it will even refuse to read les in

group writable directories. Also, sendmail will refuse to create a new aliases database in an un-

safe directory. You can get around this by manually creating the database le as a trusted user

ahead of time and then rebuilding the aliases database with newaliases.

If you are quite sure that your conguration is safe and you want sendmail to avoid these

security checks, you can turn off certain checks using the DontBlameSendmail option. This

option takes one or more names that disable checks. In the descriptions that follow, “unsafe di-

rectory” means a directory that is writable by anyone other than the owner. The values are:

Safe

No special handling.

AssumeSafeChown

Assume that the chown system call is restricted to root. Since some versions of UNIX

permit regular users to give away their les to other users on some lesystems, send-

mail often cannot assume that a givenle was created by the owner, particularly when

it is in a writable directory. You can set this ag if you know that le giveaw ay is re-

stricted on your system.

ClassFileInUnsafeDirPath

When reading class les (using the F line in the conguration le), allowles that are

in unsafe directories.

SMM:08-34

Sendmail Installation and Operation Guide

DontWarnForwardFileInUnsafeDirPath

Prevent logging of unsafe directory path warnings for non-existent forward les.

ErrorHeaderInUnsafeDirPath

Allow the le named in the ErrorHeader option to be in an unsafe directory.

FileDeliveryToHardLink

Allow delivery to les that are hard links.

FileDeliveryToSymLink

Allow delivery to les that are symbolic links.

ForwardFileInGroupWritableDirPath

Allow .forwardles in group writable directories.

ForwardFileInUnsafeDirPath

Allow .forwardles in unsafe directories.

ForwardFileInUnsafeDirPathSafe

Allow a .forwardle that is in an unsafe directory to include references to program and

les.

GroupReadableKeyFile

Accept a group-readable key le for STARTTLS.

GroupReadableSASLDBFile

Accept a group-readable Cyrus SASL password le.

GroupReadableDefaultAuthInfoFile

Accept a group-readable DefaultAuthInfo le for SASL.

GroupWritableAliasFile

Allow group-writable alias les.

GroupWritableDirPathSafe

Change the denition of “unsafe directory” to consider group-writable directories to be

safe. World-writable directories are always unsafe.

GroupWritableForwardFile

Allow group writable .forwardles.

GroupWritableForwardFileSafe

Accept group-writable .forwardles as safe for program and le delivery.

GroupWritableIncludeFile

Allow group writable :include:les.

GroupWritableIncludeFileSafe

Accept group-writable :include:les as safe for program and le delivery.

GroupWritableSASLDBFile

Accept a group-writable Cyrus SASL password le.

HelpFileInUnsafeDirPath

Allow the le named in the HelpFile option to be in an unsafe directory.

IncludeFileInGroupWritableDirPath

Allow :include:les in group writable directories.

IncludeFileInUnsafeDirPath

Allow :include:les in unsafe directories.

IncludeFileInUnsafeDirPathSafe

Allow a :include:le that is in an unsafe directory to include references to program

and les.

Sendmail Installation and Operation Guide

SMM:08-35

InsufcientEntropy

Try to use STARTTLS even if the PRNG for OpenSSL is not properly seeded despite

the security problems.

LinkedAliasFileInWritableDir

Allow an alias le that is a link in a writable directory.

LinkedClassFileInWritableDir

Allow class les that are links in writable directories.

LinkedForwardFileInWritableDir

Allow .forwardles that are links in writable directories.

LinkedIncludeFileInWritableDir

Allow :include:les that are links in writable directories.

LinkedMapInWritableDir

Allow map les that are links in writable directories. This includes alias database les.

LinkedServiceSwitchFileInWritableDir

Allow the service switch le to be a link even if the directory is writable.

MapInUnsafeDirPath

Allow maps (e.g., hash, btree, and dbmles) in unsafe directories. This includes alias

database les.

NonRootSafeAddr

Do not mark le and program deliveries as unsafe if sendmail is not running with root

privileges.

RunProgramInUnsafeDirPath

Run programs that are in writable directories without logging a warning.

RunWritableProgram

Run programs that are group- or world-writable without logging a warning.

TrustStickyBit

Allow group or world writable directories if the sticky bit is set on the directory. Do

not set this on systems which do not honor the sticky bit on directories.

WorldWritableAliasFile

Accept world-writable alias les.

WorldWritableForwardle

Allow world writable .forwardles.

WorldWritableIncludele

Allow world writable :include:les.

WriteMapToHardLink

Allow writes to maps that are hard links.

WriteMapToSymLink

Allow writes to maps that are symbolic links.

WriteStatsToHardLink

Allow the status le to be a hard link.

WriteStatsToSymLink

Allow the status le to be a symbolic link.

4.10. Connection Caching

When processing the queue, sendmail will try to keep the last few open connections open to

avoid startup and shutdown costs. This only applies to IPC and LPC connections.

SMM:08-36

Sendmail Installation and Operation Guide

When trying to open a connection the cache is rst searched. If an open connection is found,

it is probed to see if it is still active by sending a RSET command. It is not an error if this fails; in-

stead, the connection is closed and reopened.

Tw o parameters control the connection cache. The ConnectionCacheSize (k) option denes

the number of simultaneous open connections that will be permitted. If it is set to zero, connections

will be closed as quickly as possible. The default is one. This should be set as appropriate for your

system size; it will limit the amount of system resources that sendmail will use during queue runs.

Never set this higher than 4.

The ConnectionCacheTimeout (K) option species the maximum time that any cached con-

nection will be permitted to idle. When the idle time exceeds this value the connection is closed.

This number should be small (under ten minutes) to prevent you from grabbing too many resources

from other hosts. The default is ve minutes.

4.11. Name Server Access

Control of host address lookups is set by the hosts service entry in your service switch le. If

you are on a system that has built-in service switch support (e.g., Ultrix, Solaris, or DEC OSF/1)

then your system is probably congured properly already. Otherwise, sendmail will consult the le

/etc/mail/service.switch, which should be created. Sendmail only uses two entries: hosts and

aliases, although system routines may use other services (notably the passwd service for user name

lookups by getpwname).

However, some systems (such as SunOS 4.X) will do DNS lookups regardless of the setting

of the service switch entry. In particular, the system routine gethostbyname(3) is used to look up

host names, and many vendor versions try some combination of DNS, NIS, and le lookup in

/etc/hosts without consulting a service switch. Sendmail makes no attempt to work around this

problem, and the DNS lookup will be done anyway. If you do not have a nameserver congured at

all, such as at a UUCP-only site, sendmail will get a “connection refused” message when it tries to

connect to the name server. If the hosts switch entry has the service “dns” listed somewhere in the

list, sendmail will interpret this to mean a temporary failure and will queue the mail for later 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 ags as documented in resolver(3) (with the leading “RES_” deleted). Each

can be preceded by an optional ‘+’ or ‘’. For example, the line

O ResolverOptions=+AAONLYDNSRCH

turns on the AAONLY (accept authoritative answers only) and turns off the DNSRCH (search the

domain path) options. Most resolver libraries default DNSRCH, DEFNAMES, and RECURSE

ags on and all others off. If NETINET6 is enabled, most libraries default to USE_INET6 as well.

You can also include “HasWildcardMX” to specify that there is a wildcard MX record matching

your domain; this turns off MX matching when canonifying names, which can lead to inappropriate

canonications. Use “WorkAroundBrokenAAAA” when faced with a broken nameserver that re-

turns SERVFAIL (a temporary failure) on T_AAAA (IPv6) lookups during hostname canonica-

tion. Notice: it might be necessary to apply the same (or similar) options to submit.cf too.

Version level 1 congurations (see the section about ‘‘Conguration Version Level’’) turn

DNSRCH and DEFNAMES off when doing delivery lookups, but leave them on everywhere else.

Version 8 of sendmail ignores them when doing canonication lookups (that is, when using $[ ...

$]), and always does the search. If you don’t want to do automatic name extension, don’t call $[ ...

$].

Sendmail Installation and Operation Guide

SMM:08-37

The search rules for $[ ... $] are somewhat different than usual. If the name being looked up

has at least one dot, it always tries the unmodied name rst. If that fails, it tries the reduced search

path, and lastly tries the unmodied name (but only for names without a dot, since names with a dot

have already been tried). This allows names such as ‘‘utc.CS’’ to match the site in Czechoslovakia

rather than the site in your local Computer Science department. It also prefers A and CNAME

records over MX records — that is, if it nds an MX record it makes note of it, but keeps looking.

This way, if you have a wildcard MX record matching your domain, it will not assume that all

names match.

To completely turn off all name server access on systems without service switch support

(such as SunOS 4.X) you will have to recompile with DNAMED_BIND=0 and remove lresolv

from the list of libraries to be searched when linking.

4.12. Moving the Per-User Forward Files

Some sites mount each user’s home directory from a local disk on their workstation, so that

local access is fast. However, the result is that .forward le lookups from a central mail server are

slow. In some cases, mail can even be delivered on machines inappropriately because of a le

server being down. The performance can be especially bad if you run the automounter.

The ForwardPath (J) option allows you to set a path of forward les. For example, the con-

g le line

O ForwardPath=/var/forward/$u:$z/.forward.$w

would rst look for a le with the same name as the user’s login in /var/forward; if that is not found

(or is inaccessible) the le ‘‘.forward.machinename’’ in the user’s home directory is searched. A

truly perverse site could also search by sender by using $r, $s, or $f.

If you create a directory such as /var/forward, it should be mode 1777 (that is, the sticky bit

should be set). Users should create the les mode 0644. Note that you must use the ForwardFileIn-

UnsafeDirPath and ForwardFileInUnsafeDirPathSafe ags with the DontBlameSendmail option to

allow forward les in a world writable directory. This might also be used as a denial of service at-

tack (users could create forward les for other users); a better approach might be to create /var/for-

ward mode 0755 and create empty les for each user, owned by that user, mode 0644. If you do

this, you don’t hav e to set the DontBlameSendmail options indicated above.

4.13. Free Space

On systems that have one of the system calls in the statfs(2) family (including statvfs and us-

tat), you can specify a minimum number of free blocks on the queue lesystem using the MinFree-

Blocks (b) option. If there are fewer than the indicated number of blocks free on the lesystem on

which the queue is mounted the SMTP server will reject mail with the 452 error code. This invites

the SMTP client to try again later.

Beware of setting this option too high; it can cause rejection of email when that mail would

be processed without difculty.

4.14. Maximum Message Size

To avoid overowing your system with a large message, the MaxMessageSize option can be

set to set an absolute limit on the size of any one message. This will be advertised in the ESMTP

dialogue and checked during message collection.

4.15. Privacy Flags

The PrivacyOptions (p) option allows you to set certain ‘‘privacy’’ ags. Actually, many of

them don’t giv e you any extra privacy, rather just insisting that client SMTP servers use the HELO

command before using certain commands or adding extra headers to indicate possible spoof

SMM:08-38

Sendmail Installation and Operation Guide

attempts.

The option takes a series of ag names; the nal privacy is the inclusive or of those ags. For

example:

O PrivacyOptions=needmailhelo, noexpn

insists that the HELO or EHLO command be used before a MAIL command is accepted and dis-

ables the EXPN command.

The ags are detailed in section 5.6.

4.16. Send to Me Too

Beginning with version 8.10, sendmail includes by default the (envelope) sender in any list

expansions. For example, if “matt” sends to a list that contains “matt” as one of the members he

will get a copy of the message. If the MeToo option is set to FALSE (in the conguration le or via

the command line), this behavior is changed, i.e., the (envelope) sender is excluded in list expan-

sions.

5. THE WHOLE SCOOP ON THE CONFIGURATION FILE

This section describes the conguration le in detail.

There is one point that should be made clear immediately: the syntax of the conguration le is

designed to be reasonably easy to parse, since this is done every time sendmail starts up, rather than

easy for a human to read or write. The conguration le should be generated via the method described

in cf/README, it should not be edited directly unless someone is familiar with the internals of the

syntax described here and it is not possible to achieve the desired result via the default method.

The conguration le is organized as a series of lines, each of which begins with a single charac-

ter dening the semantics for the rest of the line. Lines beginning with a space or a tab are continuation

lines (although the semantics are not well dened in many places). Blank lines and lines beginning

with a sharp symbol (‘#’) are comments.

5.1. R and S — Rewriting Rules

The core of address parsing are the rewriting rules. These are an ordered production system.

Sendmail scans through the set of rewriting rules looking for a match on the left hand side (LHS) of

the rule. When a rule matches, the address is replaced by the right hand side (RHS) of the rule.

There are several sets of rewriting rules. Some of the rewriting sets are used internally and

must have specic semantics. Other rewriting sets do not have specically assigned semantics, and

may be referenced by the mailer denitions or by other rewriting sets.

The syntax of these two commands are:

Sn

Sets the current ruleset being collected to n. If you begin a ruleset more than once it appends to the

old denition.

Rlhs rhs comments

The elds must be separated by at least one tab character; there may be embedded spaces in the

elds. The lhs is a pattern that is applied to the input. If it matches, the input is rewritten to the rhs.

The comments are ignored.

Macro expansions of the form $x are performed when the conguration le is read. A literal

$ can be included using $$. Expansions of the form $&x are performed at run time using a some-

what less general algorithm. This is intended only for referencing internally dened macros such as

$h that are changed at runtime.

Sendmail Installation and Operation Guide

SMM:08-39

5.1.1. The left hand side

The left hand side of rewriting rules contains a pattern. Normal words are simply

matched directly. Metasyntax is introduced using a dollar sign. The metasymbols are:

$*

Match zero or more tokens

$+

Match one or more tokens

$

Match exactly one token

$=x Match any phrase in class x

x Match any word not in class x

If any of these match, they are assigned to the symbol $n for replacement on the right hand side,

where n is the index in the LHS. For example, if the LHS:

$:$+

is applied to the input:

UCBARPA:eric

the rule will match, and the values passed to the RHS will be:

$1 UCBARPA

$2 eric

Additionally, the LHS can include $@ to match zero tokens. This 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.

5.1.2. The right hand side

When the left hand side of a rewriting rule matches, the input is deleted and replaced by

the right hand side. Tokens are copied directly from the RHS unless they begin with a dollar

sign. Metasymbols are:

$n

Substitute indenite token n from LHS

$[name$]

Canonicalize name

$(map key $@arguments $:default $)

Generalized keyed mapping function

$>n

“Call” ruleset n

$#mailer

Resolve to mailer

$@host

Specify host

$:user

Specify user

The $n syntax substitutes the corresponding value from a $+, $, $*, $=, or match on

the LHS. It may be used anywhere.

A host name enclosed between $[ and $] is looked up in the host database(s) and replaced

by the canonical name14. For example, “$[ftp$]” might become “ftp.CS.Berkeley.EDU” and

“$[[128.32.130.2]$]” would become “vangogh.CS.Berkeley.EDU.” Sendmail recognizes its nu-

meric IP address without calling the name server and replaces it with its canonical name.

The $( ... $) syntax is a more general form of lookup; it uses a named map instead of an

implicit map. If no lookup is found, the indicated default is inserted; if no default is specied

and no lookup matches, the value is left unchanged. The arguments are passed to the map for

possible use.

The $>n syntax causes the remainder of the line to be substituted as usual and then passed

as the argument to ruleset n. The nal value of ruleset n then becomes the substitution for this

14This is actually completely equivalent to $(host hostname$). In particular, a $: default can be used.

SMM:08-40

Sendmail Installation and Operation Guide

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 ex-

ample,

$>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, a subroutine of ruleset zero, or rulesets

that return decisions (e.g., check_rcpt). It causes evaluation of the ruleset to terminate immedi-

ately, and signals to sendmail that the address has completely resolved. The complete syntax for

ruleset 0 is:

$#mailer $@host $:user

This species the {mailer, host, user} 3-tuple (triple) necessary to direct the mailer. Note: the

third element ( user ) is often also called address part. If the mailer is local the host part may be

omitted15. The mailer must be a single word, but the host and user may be multi-part. If the

mailer is the built-in IPC mailer, the host may be a colon (or comma) separated list of hosts.

Each is separately MX expanded and the results are concatenated to make (essentially) one long

MX list. Hosts separated by a comma have the same MX preference, and for each colon sepa-

rated host the MX preference is increased. The user is later rewritten by the mailer-specic en-

velope rewriting set and assigned to the $u macro. As a special case, if the mailer specied has

the F=@ag specied and the rst character of the $: value is “@”, the “@” is stripped off, and

aag is set in the address descriptor that causes sendmail to not do ruleset 5 processing.

Normally, a rule that matches is retried, that is, the rule loops until it fails. A RHS may

also be preceded by a $@ or a $: to change this behavior. A $@ prex causes the ruleset to re-

turn with the remainder of the RHS as the value. A $: prex causes the rule to terminate imme-

diately, but the ruleset to continue; this can be used to avoid continued application of a rule. The

prex is stripped before continuing.

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

R$+

$: $>7 $1

matches anything, passes that to ruleset seven, and continues; the $: is necessary to avoid an in-

nite loop.

Substitution occurs in the order described, that is, parameters from the LHS are substi-

tuted, hostnames are canonicalized, “subroutines” are called, and nally $#, $@, and $: are pro-

cessed.

5.1.3. Semantics of rewriting rule sets

There are six rewriting sets that have specic semantics. Five of these are related as de-

picted by gure 1.

Ruleset three should turn the address into “canonical form.” This form should have the

basic syntax:

local-part@host-domain-spec

Ruleset three is applied by sendmail before doing anything with any address.

If no “@” sign is specied, then the host-domain-spec may be appended (box “D” in Fig-

ure 1) from the sender address (if the Cag is set in the mailer denition corresponding to the

sending mailer).

15You may want to use it for special “per user” extensions. For example, in the address “jgm+foo@CMU.EDU”; 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-41

Figure 1 - Rewriting set semantics

Ruleset zero is applied after ruleset three to addresses that are going to actually specify re-

cipients. It must resolve to a {mailer, host, address} triple. The mailer must be dened in the

mailer denitions from the conguration le. The host is dened into the $h macro for use in

the argv expansion of the specied mailer. Notice: since the envelope sender address will be

used if a delivery status notication must be send, i.e., it may specify a recipient, it is also run

through ruleset zero. If ruleset zero returns a temporary error 4xy then delivery is deferred.

This can be used to temporarily disable delivery, e.g., based on the time of the day or other vary-

ing parameters. It should not be used to quarantine e-mails.

Rulesets one and two are applied to all sender and recipient addresses respectively. They

are applied before any specication in the mailer denition. They must never resolve.

Ruleset four is applied to all addresses in the message. It is typically used to translate in-

ternal to external form.

In addition, ruleset 5 is applied to all local addresses (specically, those that resolve to a

mailer with the ‘F=5’ ag set) that do not have aliases. This allows a last minute hook for local

names.

5.1.4. Ruleset hooks

A few extra rulesets are dened as “hooks” that can be dened to get special features.

They are all named rulesets. The “check_*” forms all give accept/reject status; falling off the

end or returning normally is an accept, and resolving to $#error is a reject or quarantine. Quar-

antining is chosen by specifying quarantine in the second part of the mailer triplet:

$#error $@ quarantine $: Reason for quarantine

Many of these can also resolve to the special mailer name $#discard; this accepts the message

as though it were successful but then discards it without delivery. Note, this mailer cannot be

chosen as a mailer in ruleset 0. Note also that all “check_*” rulesets have to deal with tempo-

rary failures, especially for map lookups, themselves, i.e., they should return a temporary error

code or at least they should make a proper decision in those cases.

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 thebs option. It is passed

SMM:08-42

Sendmail Installation and Operation Guide

client.host.name $| client.host.address

where $| is a metacharacter separating the two parts. This ruleset can reject connections

from various locations. Note that it only checks the connecting SMTP client IP address and

hostname. It does not check for third party message relaying. The check_rcpt ruleset dis-

cussed below usually does third party message relay checking.

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_data

The check_data ruleset is called after the SMTP DAT A command, its parameter is the

number of recipients. It can accept or reject the command.

5.1.4.5. check_other

The check_other ruleset is invoked for all unknown SMTP commands and for com-

mands which do not have specic rulesets, e.g., NOOP and VERB. Internal checks, e.g.,

those explained in "Measures against Denial of Service Attacks", are performed rst. The

ruleset is passed

entire-SMTP-command $| SMTP-reply-rst-digit

where $| is a metacharacter separating the two parts. For example,

VERB $| 2

reects receiving the "VERB" SMTP command and the intent to return a "2XX" SMTP suc-

cess reply. Alternatively,

JUNK TYPE=I $| 5

reects receiving the unknown "JUNK TYPE=I" SMTP command and the intent to return a

"5XX" SMTP failure reply. If the ruleset returns the SMTP reply code 421:

$#error $@ 4.7.0 $: 421 bad command

the session is terminated. Note: it is a bad idea to return the original command in the error

text to the client as that might be abused for certain attacks. The ruleset cannot override a

rejection triggered by the built-in rules.

5.1.4.6. 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 be-

tween these two addresses much like the checkcompat() function. Note: while other check_*

rulesets are invoked during the SMTP mail receiption stage (i.e., in the SMTP server),

check_compat is invoked during the mail delivery stage.

5.1.4.7. check_eoh

The check_eoh ruleset is passed

Sendmail Installation and Operation Guide

SMM:08-43

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:

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.8. check_eom

The check_eom ruleset is called after the end of a message, its parameter is the mes-

sage size. It can accept or reject the message.

5.1.4.9. 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.10. 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.11. 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.12. clt_features

The clt_features ruleset is called with the server’s host name before sendmail connects

to it (only if sendmail is compiled with STARTTLS or SASL). This ruleset should return $#

followed by a list of options (single characters delimited by white space). If the return value

SMM:08-44

Sendmail Installation and Operation Guide

starts with anything else it is silently ignored. Generally upper case characters turn off a fea-

ture while lower case characters turn it on. Options ‘D’/‘M’ cause the client to not use

DANE/MTA-STS, respectively, which is useful to interact with MTAs that have broken

DANE/MTA-STS setups by simply not using it. Note: The d option in tls_clt_features to

turn off DANE does not work when the server does not even offer STARTTLS.

5.1.4.13. 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.14. tls_client

The tls_client ruleset is called when sendmail acts as server: after a STARTTLS com-

mand has been issued and the TLS handshake was performed, 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, for

STARTTLS this happens for (most) subsequent commands.

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

5.1.4.16. tls_rcpt

The tls_rcpt ruleset is called each time before a RCPT command is sent. The parame-

ter is the current recipient. If the ruleset does resolve to the “error” mailer, the RCPT com-

mand is suppressed (treated as non-deliverable with a permanent or temporary error). This

ruleset allows to require encryption or verication of the recipient’s MTA even if the mail is

somehow redirected to another host. For example, sending mail to luke@endmail.org may

get redirected to a host named death.star and hence the tls_server ruleset won’t apply. By

introducing per recipient restrictions such attacks (e.g., via DNS spoong) can be made im-

possible. See cf/README how this ruleset can be used.

5.1.4.17. srv_features

The srv_features ruleset is called with the connecting client’s host name when a client

connects to sendmail. This ruleset should return $# followed by a list of options (single

characters delimited by white space). If the return value starts with anything else it is

silently ignored. Generally upper case characters turn off a feature while lower case charac-

ters turn it on. Option ‘S’ causes the server not to offer STARTTLS, which is useful to inter-

act with MTAs/MUAs that have broken STARTTLS implementations by simply not offering

it. ‘V’ turns off the request for a client certicate during the TLS handshake. Options ‘A’

and ‘P’ suppress SMTP AUTH and PIPELINING, respectively. ‘c’ is the equivalent to Au-

thOptions=p, i.e., it doesn’t permit mechanisms susceptible to simple passive attack (e.g.,

PLAIN, LOGIN), unless a security layer is active. Option ‘l’ requires SMTP AUTH for a

connection. Options ’B’, ’D’, ’E’, and ’X’ suppress SMTP VERB, DSN, ETRN, and

EXPN, respectively. If a client sends one of the (HTTP) commands GET, POST, CON-

NECT, or USER the connection is immediately terminated in the following cases: if sent as

rst command, if sent as rst command after STARTTLS, or if the ’h’ option is set.

Sendmail Installation and Operation Guide

SMM:08-45

A

Do not offer AUTH

a

Offer AUTH (default)

B

Do not offer VERB

b

Offer VERB (default)

C

Do not require security layer for

plaintext AUTH (default)

c

Require security layer for plaintext AUTH

D

Do not offer DSN

d

Offer DSN (default)

E

Do not offer ETRN

e

Offer ETRN (default)

h

Terminate session after HTTP commands

L

Do not require AUTH (default)

l

Require AUTH

P

Do not offer PIPELINING

p

Offer PIPELINING (default)

S

Do not offer STARTTLS

s

Offer STARTTLS (default)

V

Do not request a client certicate

v

Request a client certicate (default)

X

Do not offer EXPN

x

Offer EXPN (default)

Note: the entries marked as ‘‘(default)’’ may require that some conguration has been made,

e.g., SMTP AUTH is only available if properly congured. Moreover, many options can be

changed on a global basis via other settings as explained in this document, e.g., via Daemon-

PortOptions.

The ruleset may return ‘$#temp’ to indicate that there is a temporary problem deter-

mining the correct features, e.g., if a map is unavailable. In that case, the SMTP server is-

sues a temporary failure and does not accept email.

5.1.4.18. try_tls

The try_tls ruleset is called when sendmail connects to another MTA. The argument

for the ruleset is the name of the server. If the ruleset does resolve to the “error” mailer,

sendmail does not try STARTTLS even if it is offered. This is useful to deal with START-

TLS interoperability issues by simply not using it.

5.1.4.19. tls_srv_features and tls_clt_features

The tls_clt_features ruleset is called right before sendmail issues the STARTTLS com-

mand to another MTA and the tls_srv_features ruleset is called when a client sends the

STARTTLS command to sendmail. The arguments for the rulesets are the host name and IP

address of the other side separated by $| (which is a metacharacter). They should return a

list of key=value pairs separated by semicolons; the list can be empty if no options should be

applied to the connection. Av ailable keys are and their allowed values are:

Options

A comma separated list of SSL related options. See ServerSSLOptions and ClientSS-

LOptions for details, as well as SSL_set_options(3) and note this warning: Options al-

ready set before are not cleared!

CipherList

Specify cipher list for STARTTLS (does not apply to TLSv1.3), see ciphers(1) for possi-

ble values. This overrides the global CipherList for the session.

SMM:08-46

Sendmail Installation and Operation Guide

CertFile

File containing a certicate.

Ke yFile

File containing the private key for the certicate.

Flags

Currently the only valid ags are

R to require a CRL for each encountered certicate during verication (by default a

missing CRL is ignored),

c and C which basically clears/sets the option TLSFallbacktoClear for just this session,

respectively,

d to turn off DANE which is obviously only valid for tls_clt_features and requires DANE

to be compiled in. This might be needed in case of a misconguration, e.g., specifying

invalid TLSA RRs.

Example:

Stls_srv_features

R$* $| 10.$+

$: cipherlist=HIGH

Notes:

Errors in these features (e.g., unknown keys or inv alid values) are logged and the cur-

rent session is aborted to avoid using STARTTLS with features that should have been

changed.

The keys are case-insensitive.

Both CertFile and Ke yFile must be specied together; specifying only one is an error.

5.1.4.20. authinfo

The authinfo ruleset is called when sendmail tries to authenticate to another MTA.

The arguments for the ruleset are the host name and IP address of the server separated by $|

(which is a metacharacter). It should return $# followed by a list of tokens that are used for

SMTP AUTH. If the return value starts with anything else it is silently ignored. Each token

is a tagged string of the form: "TDstring" (including the quotes), where

T

Tag which describes the item

D

Delimiter: ’:’ simple text follows

’=’ string is base64 encoded

string

Value of the item

Valid values for the tag are:

U

user (authorization) id

I

authentication id

P

password

R

realm

M

list of mechanisms delimited by spaces

If this ruleset is dened, the option DefaultAuthInfo is ignored (even if the ruleset does not

return a ‘‘useful’’ result).

5.1.4.21. queuegroup

The queuegroup ruleset is used to map a recipient address to a queue group name.

The input for the ruleset is the recipient address (i.e., the address part of the resolved triple)

The ruleset should return $# followed by the name of a queue group. If the return value

starts with anything else it is silently ignored. See the section about ‘‘Queue Groups and

Queue Directories’’ for further information.

Sendmail Installation and Operation Guide

SMM:08-47

5.1.4.22. greet_pause

The greet_pause ruleset is used to specify the amount of time to pause before sending

the initial SMTP 220 greeting. The arguments for the ruleset are the host name and IP ad-

dress of the client separated by $| (which is a metacharacter). If any trafc is received dur-

ing that pause, an SMTP 554 rejection response is given instead of the 220 greeting and all

SMTP commands are rejected during that connection. This helps protect sites from open

proxies and SMTP slammers. The ruleset should return $# followed by the number of mil-

liseconds (thousandths of a second) to pause. If the return value starts with anything else or

is not a number, it is silently ignored. Note: this ruleset is not invoked (and hence the feature

is disabled) when smtps (SMTP over SSL) is used, i.e., the s modier is set for the daemon

via DaemonPortOptions, because in this case the SSL handshake is performed before the

greeting is sent.

5.1.5. IPC mailers

Some special processing occurs if the ruleset zero resolves to an IPC mailer (that is, a

mailer that has “[IPC]” listed as the Path in the M conguration line. The host name passed af-

ter “$@” has MX expansion performed if not delivering via a named socket; this looks the name

up in DNS to nd alternate delivery sites.

The host name can also be provided as a dotted quad or an IPv6 address in square brack-

ets; for example:

[128.32.149.78]

or

[IPv6:2002:c0a8:51d2::23f4]

This causes direct conversion of the numeric value to an IP host address.

The host name passed in after the “$@” may also be a colon or comma separated list of

hosts. Each is separately MX expanded and the results are concatenated to make (essentially)

one long MX list. Hosts separated by a comma have the same MX preference, and for each

colon separated host the MX preference is increased. The intent here is to create “fake” MX

records that are not published in DNS for private internal networks.

As a nal special case, the host name can be passed in as a text string in square brackets:

[ucbvax.berkeley.edu]

This form avoids the MX mapping. N.B.: This is intended only for situations where you have a

network rewall or other host that will do special processing for all your mail, so that your MX

record points to a gateway machine; this machine could then do direct delivery to machines

within your local domain. Use of this feature directly violates RFC 1123 section 5.3.5: it should

not be used lightly.

5.2. D — Dene Macro

Macros are named with a single character or with a word in {braces}. The names ‘‘x’’ and

‘‘{x}’’ denote the same macro for every single character ‘‘x’’. Single character names may be se-

lected from the entire ASCII set, but user-dened macros should be selected from the set of upper

case letters only. Lower case letters and special symbols are used internally. Long names beginning

with a lower case letter or a punctuation character are reserved for use by sendmail, so user-dened

long macro names should begin with an upper case letter.

The syntax for macro denitions is:

Dx val

where x is the name of the macro (which may be a single character or a word in braces) and val is

the value it should have. There should be no spaces given that do not actually belong in the macro

SMM:08-48

Sendmail Installation and Operation Guide

value.

Macros are interpolated using the construct $x, where x is the name of the macro to be inter-

polated. This interpolation is done when the conguration le is read, except in M lines. The spe-

cial construct $&x can be used in R lines to get deferred interpolation.

Conditionals can be specied using the syntax:

$?x text1 $| text2 $.

This interpolates text1 if the macro $x is set and non-null, and text2 otherwise. The “else” ($|)

clause may be omitted.

The following macros are dened and/or used internally by sendmail for interpolation into

argv’s for mailers or for other contexts. The ones marked † are information passed into sendmail16,

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 theh com-

mand line ag.

$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 rst word must be the $j macro as specied by RFC

821. Defaults to “$j Sendmail $v ready at $b”. Commonly redened to include the congu-

ration 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”,

“foo@host.domain”, or whatever is appropriate for the receiving mailer.

$h

The recipient host. This is set in ruleset 0 from the $@ eld of a parsed address.

$i

The queue id, e.g., “f344MXxp018717”.

$j‡

The “ofcial” domain name for this site. This is fully qualied if the full qualication can be

found. It must be redened to be the fully qualied domain name if your system is not con-

gured so that information can nd 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 equiva-

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

16As of version 8.6, all of these macros have reasonable defaults. Previous versions required that they be dened.

Sendmail Installation and Operation Guide

SMM:08-49

$p

Sendmail’s process id.

$r

Protocol used to receive the message. Set from thep command line ag or by the SMTP

server code.

$s

Sender’s host name. Set from thep command line ag or by the SMTP server code (in

which case it is set to the EHLO/HELO parameter).

$t

A numeric representation of the current time in the format YYYYMMDDHHmm (4 digit

year 1900-9999, 2 digit month 01-12, 2 digit day 01-31, 2 digit hours 00-23, 2 digit minutes

00-59).

$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. See also ${client_resolve}.

${addr_type}

The type of the address which is currently being rewritten. This macro contains up to three

characters, the rst is either ‘e’ or ‘h’ for envelope/header address, the second is a space, and

the third is either ‘s’ or ‘r’ for sender/recipient address.

${alg_bits}

The maximum keylength (in bits) of the symmetric encryption algorithm used for a TLS con-

nection. This may be less than the effective keylength, which is stored in ${cipher_bits}, for

‘‘export controlled’’ algorithms.

${auth_authen}

The client’s authentication credentials as determined by authentication (only set if success-

ful). The format depends on the mechanism used, it might be just ‘user’, or ‘user@realm’, or

something similar (SMTP AUTH only).

${auth_author}

The authorization identity, i.e. the AUTH= parameter of the SMTP MAIL command if sup-

plied.

${auth_type}

The mechanism used for SMTP 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_fp}

The ngerprint of the presented certicate (STARTTLS only). Note: this macro is only de-

ned if the option CertFingerprintAlgorithm is set, in which case the specied ngerprint

algorithm is used. The valid algorithms depend on the OpenSSL version, but usually md5,

sha1, and sha256 are available. See

openssl dgst -h

for a list.

${cert_issuer}

The DN (distinguished name) of the CA (certicate authority) that signed the presented cer-

ticate (the cert issuer) (STARTTLS only).

SMM:08-50

Sendmail Installation and Operation Guide

${cert_md5}

The MD5 hash of the presented certicate (STARTTLS only). Note: this macro is only de-

ned if the option CertFingerprintAlgorithm is not set.

${cert_subject}

The DN of the presented certicate (called the cert subject) (STARTTLS only).

${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 (STARTTLS only).

${cipher_bits}

The effective keylength (in bits) of the symmetric encryption algorithm used for a TLS con-

nection.

${client_addr}

The IP address of the SMTP client. IPv6 addresses are tagged with "IPv6:" before the ad-

dress. Dened in the SMTP server only.

${client_connections}

The number of open connections in the SMTP server for the client IP address.

${client_ags}

The ags specied by the Modier= part of ClientPortOptions where ags are separated

from each other by spaces and upper case ags are doubled. That is, Modier=hA will be

represented as "h AA" in ${client_ags}, which is required for testing the ags in rulesets.

${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 ] for IPv4 and [ IPv6:nnnn:...:nnnn ] for IPv6 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. Dened in the SMTP server only. See also ${client_resolve}.

${client_port}

The port number of the SMTP client. Dened in the SMTP server only.

${client_ptr}

The result of the PTR lookup for the client IP address.

Note: this is the same as

${client_name} if and only if ${client_resolve} is OK. Dened in the SMTP server only.

${client_rate}

The number of incoming connections for the client IP address over the time interval specied

by ConnectionRateWindowSize.

${client_resolve}

Holds the result of the resolve call for ${client_name}. Possible values are:

OK

resolved successfully

FAIL

permanent lookup failure

FORGED forward lookup doesn’t match reverse lookup

TEMP

temporary lookup failure

Dened in the SMTP server only. sendmail performs a hostname lookup on the IP address of

the connecting client. Next the IP addresses of that hostname are looked up. If the client IP

address does not appear in that list, then the hostname is maybe forged. This is reected as

the value FORGED for ${client_resolve} and it also shows up in $_ as "(may be forged)".

${cn_issuer}

The CN (common name) of the CA that signed the presented certicate (STARTTLS only).

Note: if the CN cannot be extracted properly it will be replaced by one of these strings based

on the encountered error:

Sendmail Installation and Operation Guide

SMM:08-51

BadCerticateContainsNUL

CN contains a NUL character

BadCerticateTooLong

CN is too long

BadCerticateUnknown

CN could not be extracted

In the last case, some other (unspecic) error occurred.

${cn_subject}

The CN (common name) of the presented certicate (STARTTLS only). See ${cn_issuer}

for possible replacements.

${currHeader}

Header value as quoted string (possibly truncated to MAXNAME). This macro is only avail-

able in header check rulesets.

${daemon_addr}

The IP address the daemon is listening on for connections.

${daemon_family}

The network family if the daemon is accepting network connections. Possible values include

“inet”, “inet6”, “iso”, “ns”, “x.25”

${daemon_ags}

The ags for the daemon as specied by the Modier= part of DaemonPortOptions whereby

the ags are separated from each other by spaces, and upper case ags are doubled. That is,

Modier=Ea will be represented as "EE a" in ${daemon_ags}, which is required for testing

the ags in rulesets.

${daemon_info}

Some information about a daemon as a text string.

For example, “SMTP+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.

${dsn_envid}

The envelope id parameter (ENVID=) passed to sendmail as part of the envelope.

${dsn_notify}

Value of DSN NOTIFY= parameter (never, success, failure, delay, or empty string).

${dsn_ret}

Value of DSN RET= parameter (hdrs, full, or empty string).

${envid}

The envelope id parameter (ENVID=) 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 to MAXNAME the header has been truncated.

${hdr_name}

The name of the header eld for which the current header check ruleset has been called. This

is useful for a default header check ruleset to get the name of the header; the macro is only

available in header check rulesets.

SMM:08-52

Sendmail Installation and Operation Guide

${if_addr}

The IP address of the interface of an incoming connection unless it is in the loopback net.

IPv6 addresses are tagged with "IPv6:" before the address.

${if_addr_out}

The IP address of the interface of an outgoing connection unless it is in the loopback net.

IPv6 addresses are tagged with "IPv6:" before the address.

${if_family}

The IP family of the interface of an incoming connection unless it is in the loopback net.

${if_family_out}

The IP family of the interface of an outgoing connection unless it is in the loopback net.

${if_name}

The hostname associated with the interface of an incoming connection. This macro can be

used for SmtpGreetingMessage and HReceived for virtual hosting. For example:

O SmtpGreetingMessage=$?{if_name}${if_name}$|$j$. MTA

${if_name_out}

The name of the interface of an outgoing connection.

${load_avg}

The current load average.

${mail_addr}

The address part of the resolved triple of the address given for the SMTP MAIL command.

Dened in the SMTP server only.

${mail_host}

The host from the resolved triple of the address given for the SMTP MAIL command. Dened

in the SMTP server only.

${mail_mailer}

The mailer from the resolved triple of the address given for the SMTP MAIL command. De-

ned in the SMTP server only.

${msg_id}

The value of the Message-Id: header.

${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).

${nbadrcpts}

The number of bad recipients for a single message.

${nrcpts}

The number of validated recipients for a single message. Note: since recipient validation hap-

pens after check_rcpt has been called, the value in this ruleset is one less than what might be

expected.

${ntries}

The number of delivery attempts.

${opMode}

The current operation mode (from thebag).

${quarantine}

The quarantine reason for the envelope, if it is quarantined.

Sendmail Installation and Operation Guide

SMM:08-53

${queue_interval}

The queue run interval given by theqag. 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.

Dened in the SMTP server only after a RCPT command.

${rcpt_host}

The host from the resolved triple of the address given for the SMTP RCPT command. Dened

in the SMTP server only after a RCPT command.

${rcpt_mailer}

The mailer from the resolved triple of the address given for the SMTP RCPT command. De-

ned in the SMTP server only after a RCPT command.

${server_addr}

The address of the server of the current outgoing SMTP connection. For LMTP delivery the

macro is set to the name of the mailer. (only if sendmail is compiled with STARTTLS or

SASL.)

${server_name}

The name of the server of the current outgoing SMTP or LMTP connection. (only if send-

mail is compiled with STARTTLS or SASL.)

${time}

The output of the time(3) function, i.e., the number of seconds since 0 hours, 0 minutes, 0 sec-

onds, January 1, 1970, Coordinated Universal Time (UTC).

${tls_version}

The TLS/SSL version used for the connection, e.g., TLSv1.2, TLSv1; dened after START-

TLS has been used.

${total_rate}

The total number of incoming connections over the time interval specied by Connection-

RateWindowSize.

${verify}

The result of the verication of the presented cert; only dened after STARTTLS has been

used (or attempted). Possible values are:

TRUSTED

verication via DANE succeeded.

DANE_FAIL

verication via DANE failed.

OK

verication succeeded.

NO

no cert presented.

NOT

no cert requested.

FAIL

cert presented but could not be veried,

e.g., the signing CA is missing.

NONE

STARTTLS has not been performed.

CLEAR

STARTTLS has been disabled internally for a clear text delivery attempt.

TEMP

temporary error occurred.

PROT OCOL

some protocol error occurred

at the ESMTP level (not TLS).

CONFIG

tls_*_features failed due to a syntax error.

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

SMM:08-54

Sendmail Installation and Operation Guide

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 nd the fully

qualied name of the host if at all possible; it does this by calling gethostname(2) to get the current

hostname and then passing that to gethostbyname(3) which is supposed to return the canonical ver-

sion of that host name.17 Assuming this is successful, $j is set to the fully qualied name and $m is

set to the domain part of the name (everything after the rst dot). The $w macro is set to the rst

word (everything before the rst dot) if you have a lev el 5 or higher conguration le; otherwise, it

is set to the same value as $j. If the canonication is not successful, it is imperative that the cong

le set $j to the fully qualied domain name18.

The $f macro is the id of the sender as originally determined; when mailing to a specic host

the $g macro is set to the address of the sender relative to the recipient. For example, if I send to

“bollard@matisse.CS.Berkeley.EDU” from the machine “vangogh.CS.Berkeley.EDU” the $f macro

will be “eric” and the $g macro will be “eric@vangogh.CS.Berkeley.EDU.”

The $x macro is set to the full name of the sender. This can be determined in several ways. It

can be passed as ag to sendmail. It can be dened in the NAME environment variable. The third

choice is the value of the “Full-Name:” line in the header if it exists, and the fourth choice is the

comment eld of a “From:” line. If all of these fail, and if the message is being originated locally,

the full name is looked up in the /etc/passwdle.

When sending, the $h, $u, and $z macros get set to the host, user, and home directory (if lo-

cal) of the recipient. The rst 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:” eld).

The $i macro is set to the queue id on this host; if put into the timestamp line it can be extremely

useful for tracking messages. The $v macro is set to be the version number of sendmail; this is nor-

mally put in timestamps and has been proven extremely useful for debugging.

The $celd is set to the “hop count,” i.e., the number of times this message has been pro-

cessed. This can be determined by thehag on the command line or by counting the timestamps

in the message.

The $r and $selds are set to the protocol used to communicate with sendmail and the send-

ing hostname. They can be set together using thep command line ag or separately using theM

oroMags.

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, ad-

dress, and port number of the SMTP client who is invoking sendmail as a server. These can be used

in the check_* rulesets (using the $& deferred evaluation form, of course!).

5.3. C and F — Dene Classes

Classes of phrases may be dened to match on the left hand side of rewriting rules, where a

“phrase” is a sequence of characters that does not contain space characters. For example a class of

all local names for this site might be created so that attempts to send to oneself can be eliminated.

17For example, on some systems gethostname might return “foo” which would be mapped to “foo.bar.com” by gethostbyname.

18Older versions of sendmail didn’t pre-dene $j at all, so up until 8.6, cong les always had to dene $j.

Sendmail Installation and Operation Guide

SMM:08-55

These can either be dened directly in the conguration le or read in from another le. Classes are

named as a single letter or a word in {braces}. Class names beginning with lower case letters and

special characters are reserved for system use. Classes dened in cong les may be given names

from the set of upper case letters for short names or beginning with an upper case letter for long

names.

The syntax is:

Cc phrase1 phrase2...

Fcle

Fc |program

Fc [mapkey]@mapclass:mapspec

The rst form denes the class c to match any of the named words. If phrase1 or phrase2 is another

class, e.g., $=S, the contents of class S are added to class c. It is permissible to split them among

multiple lines; for example, the two forms:

CHmonet ucbmonet

and

CHmonet

CHucbmonet

are equivalent. The ‘‘F’’ forms read the elements of the class c from the namedle, program, or

map specication. Each element should be listed on a separate line. To specify an optional le, use

‘‘o’’ between the class name and the le name, e.g.,

Fc o /path/to/le

If the le can’t be used, sendmail will not complain but silently ignore it. The map form should be

an optional map key, an at sign, and a map class followed by the specication for that map. Exam-

ples include:

F{VirtHosts}@ldap:k (&(objectClass=virtHosts)(host=*)) v host

F{MyClass}foo@hash:/etc/mail/classes

will ll the class $={VirtHosts} from an LDAP map lookup and $={MyClass} from a hash data-

base map lookup of the key foo. There is also a built-in schema that can be accessed by only speci-

fying:

F{ClassName}@LDAP

This will tell sendmail to use the default schema:

k (&(objectClass=sendmailMTAClass)

(sendmailMTAClassName=ClassName)

(|(sendmailMTACluster=${sendmailMTACluster})

(sendmailMTAHost=$j)))

v sendmailMTAClassValue

Note that the lookup is only done when sendmail is initially started.

Elements of classes can be accessed in rules using $= or. The (match entries not in

class) only matches a single word; multi-word entries in the class are ignored in this context.

Some classes have internal meaning to sendmail:

$=e

contains the Content-Transfer-Encodings that can be 87 bit encoded. It is predened to

contain “7bit”, “8bit”, and “binary”.

$=k

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

$=m

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

$=n

can be set to the set of MIME body types that can never be eight to seven bit encoded. It

defaults to “multipart/signed”. Message types “message/*” and “multipart/*” are never

SMM:08-56

Sendmail Installation and Operation Guide

encoded directly. Multipart messages are always handled recursively. The handling of

message/* messages are controlled by class $=s.

$=q

A set of Content-Types that will never be encoded as base64 (if they hav e to be encoded,

they will be encoded as quoted-printable). It can have primary types (e.g., “text”) or full

types (such as “text/plain”).

$=s

contains the set of subtypes of message that can be treated recursively. By default it con-

tains only “rfc822”. Other “message/*” types cannot be 87 bit encoded. If a message

containing eight bit data is sent to a seven bit host, and that message cannot be encoded

into seven bits, it will be stripped to 7 bits.

$=t

set to the set of trusted users by the T conguration line. If you want to read trusted users

from a le, use Ft/le/name.

$=w

set to be the set of all names this host is known by. This can be used to match local host-

names.

$={persistentMacros}

set to the macros that should be saved across queue runs. Care should be taken when

adding macro names to this class.

Sendmail can be compiled to allow a scanf(3) string on the F line. This lets you do simplistic

parsing of text les. For example, to read all the user names in your system /etc/passwdle into a

class, use

FL/etc/passwd %[ˆ:]

which reads every line up to the rst colon.

5.4. M — Dene Mailer

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

Mname, {eld=value }*

where name is the name of the mailer (used internally only) and the “eld=name” pairs dene at-

tributes of the mailer. Fields are:

Path

The pathname of the mailer

Flags

Specialags for this mailer

Sender

Rewriting set(s) for sender addresses

Recipient

Rewriting set(s) for recipient addresses

recipients

Maximum number of recipients per envelope

Argv

An argument vector to pass to this mailer

Eol

The end-of-line string for this mailer

Maxsize

The maximum message length to this mailer

maxmessages

The maximum message deliveries per connection

Linelimit

The maximum line length in the message body

Directory

The working directory for the mailer

Userid

The default user and group id to run as

Nice

The nice(2) increment for the mailer

Charset

The default character set for 8-bit characters

Type

Type information for DSN diagnostics

Wait

The maximum time to wait for the mailer

Queuegroup

The default queue group for the mailer

/

The root directory for the mailer

Only the rst character of the eld name is checked (it’s case-sensitive).

The following ags may be set in the mailer description. Any other ags may be used freely

to conditionally assign headers to messages destined for particular mailers. Flags marked with † are

Sendmail Installation and Operation Guide

SMM:08-57

not interpreted by the sendmail binary; these are the conventionally used to correlate to the ags

portion of the H line. Flags marked with ‡ apply to the mailers for the sender address rather than

the usual recipient mailers.

a

Run Extended SMTP (ESMTP) protocol (dened in RFCs 1869, 1652, and 1870). This ag

defaults on if the SMTP greeting message includes the word “ESMTP”.

A

Look up the user (address) part of the resolved mailer triple, in the alias database. Normally

this is only set for local mailers.

b

Force a blank line on the end of a message. This is intended to work around some stupid ver-

sions of /bin/mail that require a blank line, but do not provide it themselves. It would not nor-

mally be used on network mail.

B

Strip leading backslashes (\) off of the address; this is a subset of the functionality of the sag.

c

Do not include comments in addresses. This should only be used if you have to work around a

remote mailer that gets confused by comments. This strips addresses of the form “Phrase <ad-

dress>” or “address (Comment)” down to just “address”.

C‡ If mail is received from a mailer with this ag set, any addresses in the header that do not have

an at sign (“@”) after being rewritten by ruleset three will have the “@domain” clause from

the sender envelope address tacked on. This allows mail with headers of the form:

From: usera@hosta

To: userb@hostb, userc

to be rewritten as:

From: usera@hosta

To: userb@hostb, userc@hosta

automatically. Howev er, it doesn’t really work reliably.

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 af fromag, 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 re-

turn address as required by RFC 1123. However, some mailers don’t accept a null return ad-

dress. If necessary, you can set the gag to prevent sendmail from obeying the standards; er-

ror 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 ag is deprecated and will be removed from a future version. This mailer will be speak-

ing SMTP to another sendmail — as such it can use special protocol features. This ag should

not be used except for debugging purposes because it uses VERB as SMTP command.

SMM:08-58

Sendmail Installation and Operation Guide

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 ac-

cidentally the same host name as might happen if sendmail is miscongured or if a long-haul

network interface is set in loopback mode. This ag disables the loopback check. It should

only be used under very unusual circumstances.

K

Currently unimplemented. Reserved for chunking.

l

This mailer is local (i.e., nal delivery will be performed).

L

Limit the line lengths as specied in RFC 821. This deprecated option should be replaced by

the L= mail declaration. For historic reasons, the Lag also sets the 7ag.

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 denition, that eld will be repeated as necessary for all

qualifying users. Removing this ag can defeat duplicate suppression 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 specied in the u option) when deliv-

ering network mail. The normal behavior is required by most local mailers, which will not al-

low the envelope sender address to be set unless the mailer is running as daemon. This ag is

ignored if the Sag is set.

p

Use the route-addr style reverse-path in the SMTP SMTP MAIL command rather than just the

return address; although this is required in RFC 821 section 3.1, many hosts do not process re-

verse-paths properly. Rev erse-paths are ofcially discouraged by RFC 1123.

P† This mailer wants a “Return-Path:” line.

q

When an address that resolves to this mailer is veried (SMTP VRFY command), generate 250

responses instead of 252 responses. This will imply that the address is local.

r

Same as f, but sends arag.

R

Open SMTP connections from a “secure” port. Secure ports aren’t (secure, that is) except on

UNIX machines, so it is unclear that this adds anything. sendmail must be running as root to

be able to use this ag.

s

Strip quote characters (" and \) off of the address before calling the mailer.

S

Don’t reset the userid before calling the mailer. This would be used in a secure environment

where sendmail ran as root. This could be used to avoid forged addresses. If the U=eld is

also specied, this ag causes the effective user id to be set to that user.

u

Upper case should be preserved in user names for this mailer. Standards require preservation

of case in the local part of addresses, except for those address for which your system accepts

responsibility. RFC 2142 provides a long list of addresses which should be case insensitive. If

you use this ag, you may be violating RFC 2142. Note that postmaster is always treated as a

case insensitive address regardless of this ag.

U

This mailer wants UUCP-style “From” lines with the ugly “remote from <host>” on the end.

w

The user must have a valid account on this machine, i.e., getpwnam must succeed. If not, the

mail is bounced. See also the MailboxDatabase option. This is required to get “.forward” ca-

pability.

W

Ignore long term host status information (see Section "Persistent Host Status Information").

x† This mailer wants a “Full-Name:” header line.

Sendmail Installation and Operation Guide

SMM:08-59

X

This mailer wants to use the hidden dot algorithm as specied in RFC 821; basically, any line

beginning with a dot will have an extra dot prepended (to be stripped at the other end). This

insures that lines in the message containing a dot will not terminate the message prematurely.

z

Run Local Mail Transfer Protocol (LMTP) between sendmail and the local mailer. This is a

variant on SMTP dened in RFC 2033 that is specically designed for delivery to a local mail-

box.

Z

Apply DialDelay (if set) to this mailer.

0

Don’t look up MX records for hosts sent via SMTP/LMTP. Do not apply FallbackMXhost ei-

ther.

1

Strip null characters (’ ’) when sending to this mailer.

2

Don’t use ESMTP even if offered; this is useful for broken systems that offer ESMTP but fail

on EHLO (without recovering when HELO is tried next).

3

Extend the list of characters converted to =XX notation when converting to Quoted-Printable to

include those that don’t map cleanly between ASCII and EBCDIC. Useful if you have IBM

mainframes on site.

5

If no aliases are found for this address, pass the address through ruleset 5 for possible alternate

resolution. This is intended to forward the mail to an alternate delivery spot.

6

Strip headers to seven bits.

7

Strip all output to seven bits. This is the default if the Lag is set. Note that clearing this op-

tion is not sufcient to get full eight bit data passed through sendmail. If the 7 option is set,

this is essentially always set, since the eighth bit was stripped on input. Note that this option

will only impact messages that didn’t hav e 87 bit MIME conversions performed.

8

If set, it is acceptable to send eight bit data to this mailer; the usual attempt to do 87 bit

MIME conversions will be bypassed.

9

If set, do limited 78 bit MIME conversions. These conversions are limited to text/plain data.

:

Check addresses to see if they begin with “:include:”; if they do, convert them to the “*in-

clude*” mailer.

|

Check addresses to see if they begin with a ‘|’; if they do, convert them to the “prog” mailer.

/

Check addresses to see if they begin with a ‘/’; if they do, convert them to the “*le*” mailer.

@

Look up addresses in the user database.

%

Do not attempt delivery on initial receipt of a message or on queue runs unless the queued

message is selected using one of the -qI/-qR/-qS queue run modiers or an ETRN request.

!

Disable an MH hack that drops an explicit From: header if it is the same as what sendmail

would generate.

Conguration les prior to level 6 assume the ‘A’, ‘w’, ‘5’, ‘:’, ‘|’, ‘/’, and ‘@’ options on the

mailer named “local”.

The mailer with the special name “error” can be used to generate a user error. The (optional)

host eld is an exit status to be returned, and the user eld is a message to be printed. The exit sta-

tus may be numeric or one of the values USAGE, NOUSER, NOHOST, UNAVAILABLE, SOFT-

WARE, TEMPFAIL, PROT OCOL, or CONFIG to return the corresponding EX_ exit code, or an

enhanced error code as described in RFC 1893, Enhanced Mail System Status Codes. For example,

the entry:

$#error $@ NOHOST $: Host unknown in this domain

on the RHS of a rule will cause the specied error to be generated and the “Host unknown” exit 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 host eld can also contain the special token quarantine which instructs

SMM:08-60

Sendmail Installation and Operation Guide

sendmail to quarantine the current message.

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 cannot be used in ruleset 0,

only in the various address checking rulesets.

The mailer named “local” must be dened in every conguration le. This is used to deliver

local mail, and is treated specially in several ways. Additionally, three other mailers named “prog”,

“*le*”, and “*include*” may be dened to tune the delivery of messages to programs, les, and

:include: lists respectively. They default to:

Mprog, P=/bin/sh, F=lsoDq9, T=DNS/RFC822/X-Unix, A=sh c $u

M*le*, P=[FILE], F=lsDFMPEouq9, T=DNS/RFC822/X-Unix, A=FILE $u

M*include*, P=/dev/null, F=su, A=INCLUDE $u

Builtin pathnames are [FILE] and [IPC], the former is used for delivery to les, the latter for

delivery via interprocess communication. For mailers that use [IPC] as pathname the argument vec-

tor (A=) must start with TCP or FILE for delivery via a TCP or a Unix domain socket. If TCP is

used, the second argument must be the name of the host to contact. Optionally a third argument can

be used to specify a port, the default is smtp (port 25). If FILE is used, the second argument must

be the name of the Unix domain socket.

If the argument vector does not contain $u then sendmail will speak SMTP (or LMTP if the

mailer ag z is specied) to the mailer.

If no Eol eld is dened, then the default is "\r\n" for SMTP mailers and "\n" of others.

The Sender and Recipient rewriting sets may either be a simple ruleset id or may be two ids

separated by a slash; if so, the rst rewriting set is applied to envelope addresses and the second is

applied to headers. Setting any value to zero disables corresponding mailer-specic rewriting.

The Directory is actually a colon-separated path of directories to try. For example, the deni-

tion “D=$z:/” rst tries to execute in the recipient’s home directory; if that is not available, it tries to

execute in the root of the lesystem. This is intended to be used only on the “prog” mailer, since

some shells (such as csh) refuse to execute if they cannot read the current directory. Since the queue

directory is not normally readable by unprivileged users csh scripts as recipients can fail.

The Userid species the default user and group id to run as, overriding the DefaultUser op-

tion (q.v.). If the S mailer ag is also specied, this user and group will be set as the effective uid

and gid for the process. This may be given as user:group to set both the user and group id; either

may be an integer or a symbolic name to be looked up in the passwd and grouples respectively. If

only a symbolic user name is specied, the group id in the passwdle for that user is used as the

group id.

The Charset eld is used when converting a message to MIME; this is the character set used

in the Content-Type: header. If this is not set, the DefaultCharSet option is used, and if that is not

set, the value “unknown-8bit” is used. WARNING: this eld applies to the 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= eld for

the local network mailer, not that of the external network mailer.

The Type= eld sets the type information used in MIME error messages as dened by RFC

1894. It is actually three values separated by slashes: the MTA-type (that is, the description of how

hosts are named), the address type (the description of e-mail addresses), and the diagnostic type (the

description of error diagnostic codes). Each of these must be a registered value or begin with “X”.

The default is “dns/rfc822/smtp”.

The m= eld species the maximum number of messages to attempt to deliver on a single

SMTP or LMTP connection. The default is innite.

Sendmail Installation and Operation Guide

SMM:08-61

The r= eld species the maximum number of recipients to attempt to deliver in a single en-

velope. It defaults to 100.

The /= eld species a new root directory for the mailer. The path is macro expanded and

then passed to the “chroot” system call. The root directory is changed before the Directory eld is

consulted or the uid is changed.

The Wait= eld species the maximum time to wait for the mailer to return after sending all

data to it. This applies to mailers that have been forked by sendmail.

The Queuegroup= eld species the default queue group in which received mail should be

queued. This can be overridden by other means as explained in section ‘‘Queue Groups and Queue

Directories’’.

5.5. H — Dene Header

The format of the header lines that sendmail inserts into the message are dened by the H

line. The syntax of this line is one of the following:

Hhname: htemplate

H[?mags?]hname: htemplate

H[?${macro}?]hname: htemplate

Continuation lines in this spec are reected directly into the outgoing message. The htemplate is

macro-expanded before insertion into the message. If the mags (surrounded by question marks)

are specied, at least one of the specied ags must be stated in the mailer denition for this header

to be automatically output. If a ${macro} (surrounded by question marks) is specied, the header

will be automatically output if the macro is set. The macro may be set using any of the normal

methods, including using the macro storage map in a ruleset. If one of these headers is in the input

it is reected to the output regardless of these ags or macros. Notice: If a ${macro} is used to set a

header, then it is useful to add that macro to class $={persistentMacros} which consists of the

macros that should be saved across queue runs.

Some headers have special semantics that will be described later.

A secondary syntax allows validation of headers as they are being read. To enable validation,

use:

HHeader: $>Ruleset

HHeader: $>+Ruleset

The indicated Ruleset is called for the specied Header, and can return $#error to reject or quaran-

tine the message or $#discard to discard the message (as with the other check_* rulesets). The

ruleset receives the header eld-body as argument, i.e., not the header eld-name; see also

${hdr_name} and ${currHeader}. The header is treated as a structured eld, that is, text in paren-

theses is deleted before processing, unless the second form $>+ is used. Note: only one ruleset can

be associated with a header; sendmail will silently ignore multiple entries.

For example, the conguration lines:

HMessage-Id: $>CheckMessageId

SCheckMessageId

R< $+ @ $+ >

$@ OK

R$*

$#error $: Illegal Message-Id header

would refuse any message that had a Message-Id: header of any of the following forms:

SMM:08-62

Sendmail Installation and Operation Guide

Message-Id: <>

Message-Id: some text

Message-Id: <legal text@domain> extra crud

A default ruleset that is called for headers which don’t hav e a specic ruleset dened for them can

be specied by:

H*: $>Ruleset

or

H*: $>+Ruleset

5.6. O — Set Option

There are a number of global options that can be set from a conguration le. Options are

represented by full words; some are also representable as single characters for back compatibility.

The syntax of this line is:

O option=value

This sets option option to be value. Note that there must be a space between the letter ‘O’ and the

name of the option. An older version is:

Oo value

where the option o is a single character. Depending on the option, value may be a string, an integer,

a boolean (with legal values “t”, “T”, “f”, or “F”; the default is TRUE), or a time interval.

All lenames used in options should be absolute paths, i.e., starting with ’/’. Relative le-

names most likely cause surprises during operation (unless otherwise noted).

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

AliasFile=spec, spec, ...

[A] Specify possible alias le(s). Each spec should be in the format ‘‘class: info’’

where class: is optional and defaults to ‘‘implicit’’. Note that info is required for

all classes except “ldap”. For the “ldap” class, if info is not specied, a default

info value is used as follows:

k (&(objectClass=sendmailMTAAliasObject)

(sendmailMTAAliasName=aliases)

(|(sendmailMTACluster=${sendmailMTACluster})

(sendmailMTAHost=$j))

(sendmailMTAKey=%0))

v sendmailMTAAliasValue

Depending on how sendmail is compiled, valid classes are “implicit” (search

through a compiled-in list of alias le types, for back compatibility), “hash” (if

NEWDB is specied), “btree” (if NEWDB is specied), “dbm” (if NDBM is speci-

ed), “cdb” (if CDB is specied), “stab” (internal symbol table — not normally

used unless you have no other database lookup), “sequence” (use a sequence of

maps previously declared), “ldap” (if LDAPMAP is specied), or “nis” (if NIS is

specied). If a list of specs are provided, sendmail searches them in order.

AliasWait=timeout

[a] If set, wait up to timeout (units default to minutes) for an “@:@” entry to exist

in the alias database before starting up. If it does not appear in the timeout inter-

val issue a warning.

AllowBogusHELO

If set, allow HELO SMTP commands that don’t include a host name. Setting this

violates RFC 1123 section 5.2.5, but is necessary to interoperate with several

Sendmail Installation and Operation Guide

SMM:08-63

SMTP clients. If there is a value, it is still checked for legitimacy.

AuthMaxBits=N Limit the maximum encryption strength for the security layer in SMTP AUTH

(SASL). Default is essentially unlimited. This allows to turn off additional en-

cryption in SASL if STARTTLS is already encrypting the communication, be-

cause the existing encryption strength is taken into account when choosing an al-

gorithm for the security layer. For example, if STARTTLS is used and the sym-

metric cipher is 3DES, then the keylength (in bits) is 168. Hence setting Auth-

MaxBits to 168 will disable any encryption in SASL.

AuthMechanisms List of authentication mechanisms for AUTH (separated by spaces). The adver-

tised list of authentication mechanisms will be the intersection of this list and the

list of available mechanisms as determined by the Cyrus SASL library. If START-

TLS is active, EXTERNAL will be added to this list. In that case, the value of

{cert_subject} is used as authentication id.

AuthOptions

List of options for SMTP AUTH consisting of single characters with intervening

white space or commas.

A

Use the AUTH= parameter for the MAIL

command only when authentication succeeded.

This can be used as a workaround for broken

MTAs that do not implement RFC 2554 correctly.

a

protection from active (non-dictionary) attacks

during authentication exchange.

c

require mechanisms which pass client credentials,

and allow mechanisms which can pass credentials

to do so.

d

don’t permit mechanisms susceptible to passive

dictionary attack.

f

require forward secrecy between sessions

(breaking one won’t help break next).

m

require mechanisms which provide mutual authentication

(only available if using Cyrus SASL v2 or later).

p

don’t permit mechanisms susceptible to simple

passive attack (e.g., PLAIN, LOGIN), unless a

security layer is active.

y

don’t permit mechanisms that allow anonymous login.

The rst option applies to sendmail as a client, the others to a server. Example:

O AuthOptions=p,y

would disallow ANONYMOUS as AUTH mechanism and would allow PLAIN

and LOGIN only if a security layer (e.g., provided by STARTTLS) is already ac-

tive. The options ’a’, ’c’, ’d’, ’f’, ’p’, and ’y’ refer to properties of the selected

SASL mechanisms. Explanations of these properties can be found in the Cyrus

SASL documentation.

AuthRealm

The authentication realm that is passed to the Cyrus SASL library. If no realm is

specied, $j is used. See also KNOWNBUGS.

BadRcptThrottle=N

If set and the specied number of recipients in a single SMTP transaction have

been rejected, sleep for one second after each subsequent RCPT command in that

transaction.

BlankSub=c

[B] Set the blank substitution character to c. Unquoted spaces in addresses are re-

placed by this character. Defaults to space (i.e., no change is made).

SMM:08-64

Sendmail Installation and Operation Guide

CACertPath

Path to directory with certicates of CAs. This directory directory must contain

the hashes of each CA certicate as lenames (or as links to them).

CACertFile

File containing one or more CA certicates; see section about STARTTLS for

more information.

CertFingerprintAlgorithm

Specify the ngerprint algorithm (digest) to use for the presented cert. If the op-

tion is not set, md5 is used and the macro ${cert_md5} contains the cert nger-

print. If the option is explicitly set, the specied algorithm (e.g., sha1) is used and

the macro ${cert_fp} contains the cert ngerprint.

CipherList

Specify cipher list for STARTTLS (does not apply to TLSv1.3). See ciphers(1)

for possible values.

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: eld in the user header and the P lines in the conguration le) and

subtracted from the priority. Thus, messages with a higher Priority: will be fa-

vored. Defaults to 1800.

ClientCertFile

File containing the certicate of the client, i.e., this certicate is used when send-

mail acts as client (for STARTTLS).

ClientKeyFile

File containing the private key belonging to the client certicate (for STARTTLS

if sendmail runs as client).

ClientPortOptions=options

Set client SMTP options. The options are key=value pairs separated by commas.

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

Modier

Options (ags) for the client

The Address mask may be a numeric address in IPv4 dot notation or IPv6 colon

notation or a network name. Note that if a network name is specied, only the

rst IP address returned for it will be used. This may cause indeterminate behav-

ior for network names that resolve to multiple addresses. Therefore, use of an ad-

dress is recommended. Modier can be the following character:

h

use name of interface for HELO command

A

don’t use AUTH when sending e-mail

S

don’t use STARTTLS when sending e-mail

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. However, the name must not start with a square bracket and it must

contain at least one dot. This is a simple test whether the name is not an IP ad-

dress (in square brackets) but a qualied hostname. Note that multiple ClientPor-

tOptions settings are allowed in order to give settings for each protocol family

(e.g., one for Family=inet and one for Family=inet6). A restriction placed on one

Sendmail Installation and Operation Guide

SMM:08-65

family only affects outgoing connections on that particular family.

ClientSSLOptions

A space or comma separated list of SSL related options for the client side. See

SSL_CTX_set_options(3) for a list; the available values depend on the OpenSSL

version against which

sendmail

is compiled.

By default,

SSL_OP_ALL

SSL_OP_NO_SSLv2 SSL_OP_NO_TICKET -SSL_OP_TLSEXT_PADDING are

used (if those options are available). Options can be cleared by preceding them

with a minus sign. It is also possible to specify numerical values, e.g., -0x0010.

ColonOkInAddr If set, colons are acceptable in e-mail addresses (e.g., “host:user”). If not set,

colons indicate the beginning of a RFC 822 group construct (“groupname: mem-

ber1, member2, ... memberN;”). Doubled colons are always acceptable (“node-

name::user”)

and

proper

route-addr

nesting

is

understood

(“<@re-

lay:user@host>”). Furthermore, this option defaults on if the conguration ver-

sion 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 le descriptors, the connection cache should be kept small: 4

is probably a practical maximum.

ConnectionCacheTimeout=timeout

[K] The maximum amount of time a cached connection will be permitted to idle

without activity. If this time is exceeded, the connection is immediately closed.

This value should be small (on the order of ten minutes). Before sendmail uses a

cached connection, it always sends a RSET command to check the connection; if

this fails, it reopens the connection. This keeps your end from failing if the other

end times out. The point of this option is to be a good network neighbor and

avoid using up excessive resources on the other end. The default is ve minutes.

ConnectOnlyTo=address

This can be used to override the connection address (for testing purposes).

ConnectionRateThrottle=N

If set to a positive value, allow no more than N incoming connections in a one sec-

ond period per daemon. This is intended to atten out peaks and allow the load

av erage checking to cut in. Defaults to zero (no limits).

ConnectionRateWindowSize=N

Dene the length of the interval for which the number of incoming connections is

maintained. The default is 60 seconds.

ControlSocketName=name

Name of the control socket for daemon management. A running sendmail dae-

mon can be controlled through this named socket. Available commands are: help,

mstat, 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 .

CRLFile=name

Name of le that contains certicate revocation status, useful for X.509v3 authen-

tication. Note: if a CRLFile is specied but the le is unusable, STARTTLS is

disabled.

SMM:08-66

Sendmail Installation and Operation Guide

CRLPath=name Name of directory that contains hashes pointing to certicate revocation status

les. Symbolic links can be generated with the following two (Bourne) shell

commands:

C=FileName_of_CRL

ln -s $C ‘openssl crl -noout -hash < $C‘.r0

DHParameters

This option applies to the server side only. Possible values are:

5

use precomputed 512 bit prime.

1

generate 1024 bit prime

2

generate 2048 bit prime.

i

use included precomputed 2048 bit prime (default).

none

do not use Dife-Hellman.

/path/to/le

load prime from le.

This is only required if a ciphersuite containing DSA/DH is used. The default is

‘‘i’’ which selects a precomputed, xed 2048 bit prime. If ‘‘5’’ is selected, then

precomputed, xed primes are used. Note: this option should not be used (unless

necessary for compatibility with old implementations). If ‘‘1’’ or ‘‘2’’ is selected,

then prime values are computed during startup. Note: this operation can take a

signicant amount of time on a slow machine (several seconds), but it is only

done once at startup. If ‘‘none’’ is selected, then TLS ciphersuites containing

DSA/DH cannot be used. If a