.\" Copyright (c) 1983 Eric P. Allman
.\" Copyright (c) 1983 The Regents of the University of California.
.\" %sccs.include.redist.roff%
.\" @(#)op.me 6.3 (Berkeley) %G%
.\" eqn op.me | pic | troff -me
.eh 'SMM:07-%''Sendmail Installation and Operation Guide'
.oh 'Sendmail Installation and Operation Guide''SMM:07-%'
.\" SD is lib if sendmail is installed in /usr/lib, sbin if in /usr/sbin
.b "INSTALLATION AND OPERATION GUIDE"
University of California, Berkeley
implements a general purpose internetwork mail routing facility
*UNIX is a trademark of Bell Laboratories.
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.
it can do a limited amount of message header editing
to put the message into a format that is appropriate
for the receiving domain.
All of this is done under the control of a configuration file.
Due to the requirements of flexibility
the configuration file can seem somewhat unapproachable.
However, there are only a few basic configurations
for which standard configuration files have been supplied.
Most other configurations
can be built by adjusting an existing configuration files
RFC822 (Internet Mail Format Protocol),
RFC821 (Simple Mail Transport Protocol),
RFC1123 (Internet Host Requirements).
is designed to work in a wider world,
in many cases it can be configured to exceed these protocols.
These cases are described herein.
without the need for monitoring,
it has a number of features
that may be used to monitor or adjust the operation
under unusual circumstances.
These features are described.
Section one describes how to do a basic
explains the day-to-day information you should know
to maintain your mail system.
If you have a relatively normal site,
these two sections should contain sufficient information
describes some parameters that may be safely tweaked.
has information regarding the command line arguments.
contains the nitty-gritty information about the configuration
This section is for masochists
and people who must write their own configuration file.
gives a brief description of differences
The appendixes give a brief
but detailed explanation of a number of features
not described in the rest of the paper.
.sh 1 "BASIC INSTALLATION"
This section is a very rough rewrite;
please don't assume that it is already completely correct.
please send me suggestions so that later versions of this document
There are two basic steps to installing sendmail.
The hard part is to build the configuration table.
This is a file that sendmail reads when it starts up
that describes the mailers it knows about,
how to rewrite the message header,
and the settings of various options.
Although the configuration table is quite complex,
a configuration can usually be built
by adjusting an existing off-the-shelf configuration.
The second part is actually doing the installation,
i.e., creating the necessary files, etc.
The remainder of this section will describe the installation of sendmail
assuming you can use one of the existing configurations
and that the standard installation parameters are acceptable.
All pathnames and examples
are given from the root of the
.i /usr/src/usr.\*(SD/sendmail
If you are loading this off the tape,
continue with the next session.
If you have a running binary already on your system,
you should probably skip to section 1.2.
.sh 2 "Compiling Sendmail"
All sendmail source is in the
If you are running on a 4.4BSD system,
On other systems, you may have to make some other adjustments.
.sh 3 "Old versions of make"
If you are not running the new version of
you will probably have to use
This file does not assume several new syntaxes,
syntax in macro definition
.sh 3 "Compilation flags"
supports three different formats
The old, tried and somewhat-true
A newer version of the above.
This was the preferred format prior to 4.4BSD.
It allows such complex things as multiple databases
and closing a currently open database.
The new database package from Berkeley.
If you have this, use it.
You can define this in conjunction with one of the other two;
but when a new database is created it will be in NEWDB format.
if you have both NEWDB and one of the DB formats defined,
will create both new and old versions of the alias file
This is required because the Sun NIS/YP system
reads the DBM version of the alias file.
If none of these are defined,
reads the alias file into memory on every invocation.
This can be slow and should be avoided.
System V based systems can define
to make several small adjustments.
This changes the handling of timezones
and uses the much less efficient
These can be specified separately using the compilation flags
routine in your system library, define the UNSETENV compilation flag.
You may also have to define the compilation variable LA_TYPE
to describe how your load average is computed.
This is described in detail in section 6.1.
.sh 3 "Compilation and installation"
After making the local system configuration described above,
You should be able to compile and install the system.
Compilation can be performed using
\**where you may have to replace
.q "make \-f Makefile.dist"
You may be able to install using
This should install the binary in
On BSD4.4 systems it will also format and install man pages.
.sh 2 "Configuration Files"
cannot operate without a configuration file.
The configuration defines the mail systems understood at this site,
how to forward email to remote mail systems,
and a number of tuning parameters.
This configuration file is detailed
in the later portion of this document.
configuration can be daunting at first.
and the mail configuration reflects that.
The distribution includes an m4-based configuration package
that hides a lot of the complexity.
These configuration files are simpler than old versions
largely because the world has become simpler;
text-based host files are officially eliminated,
hosts behind a registered internet gateway.
These files also assume that most of your neighbors
use domain-based UUCP addressing;
instead of naming hosts as
The configuration files can be customized to work around this,
I haven't tested these yet on an isolated LAN environment
with a single UUCP connection to the outside world.
If you are in such an environment,
sendmail@okeeffe.CS.Berkeley.EDU.
Our configuration files are processed by
to facilitate local customization;
contains the source files.
This directory contains several subdirectories:
Both site-dependent and site-independent descriptions of hosts.
These can be literal host names
when the hosts are gateways
or more general descriptions
as a general description of an SMTP-connected host
as a general description of a UUCP-connected host).
(``Master Configuration'')
are the input descriptions;
the output is in the corresponding
The general structure of these files is described below.
Site-dependent subdomain descriptions.
These are tied to the way your organization wants to do addressing.
is our description for hosts in the CS.Berkeley.EDU subdomain
that want their individual hostname to be externally visible;
is the same except that the hostname is hidden
(everything looks like it comes from CS.Berkeley.EDU).
These are referenced using the
Definitions of specific features that some particular host in your site
These are referenced using the
(which improves performance if you don't have a wildcard MX record
(which tells sendmail to read an /etc/sendmail.cw file on startup
to find the set of local names).
Local hacks, referenced using the
The point of having them here is to make it clear that they smell.
include files that have information common to all configuration files.
This can be thought of as a
Defined mailer types in this distribution are
Definitions describing various operating system environments
(such as the location of support files).
These are referenced using the
You shouldn't have to mess with these.
Local site configuration information,
such as UUCP connectivity.
They normally contain lists of site information, for example:
They are referenced using the SITECONFIG macro:
SITECONFIG(site.config.file, name_of_site, X)
is the macro/class name to use.
(indicating locally connected hosts)
for up to three remote UUCP hubs.
If you are in a new domain
you will probably want to create a
This consists primarily of relay definitions:
for example, Berkeley's domain definition
only the UUCP relay is particularly specific
All of these are internet-style domain names.
Please check to make certain they are reasonable for your domain.
Subdomains at Berkeley are also represented in the
is the Computer Science subdomain with the local hostname shown
makes users appear to be from the CS.Berkeley.EDU subdomain
(with no local host information included).
You will probably have to update this directory
to be appropriate for your domain.
You will have to use or create
subdirectory for your hosts.
.sh 2 "Details of Installation Files"
This subsection describes the files that
.sh 3 "/usr/\*(SD/sendmail"
The binary for sendmail is located in /usr/\*(SD\**.
on 4.4BSD and newer systems;
many systems install it in
I understand it is in /usr/ucblib
It should be setuid root.
should be owned by root, mode 755\**.
\**Some vendors ship them owned by bin;
this creates a security hole that is not actually related to
Other important directories that should have restrictive ownerships
/bin, /usr/bin, /etc, /usr/etc, /lib, and /usr/lib.
This is the configuration file for sendmail.
This and the frozen configuration file
are the only two non-library file names compiled into sendmail\**.
\**The system libraries can reference other files;
in particular, system library subroutines that
Some older systems install it in
.b /usr/lib/sendmail.cf .
If you want to move this file,
The configuration file is normally created
using the distribution files described above.
If you have a particularly unusual system configuration
you may need to create a special version.
The format of this file is detailed in later sections
.sh 3 "/usr/ucb/newaliases"
If you are running delivermail,
This can just be a link to
rm \-f /usr/ucb/newaliases
ln /usr/\*(SD/sendmail /usr/ucb/newaliases
This can be installed in whatever search path you prefer
.sh 3 "/var/spool/mqueue"
should be created to hold the mail queue.
This directory should be mode 700
The actual path of this directory
The system aliases are held in
which includes some aliases which
cp lib/aliases /etc/aliases
You should extend this file with any aliases that are apropos to your system.
looks at a version of these files maintained by the
These are stored either in
depending on which database package you are using.
These can initially be created as empty files,
but they will have to be initialized promptly.
These should be mode 644:
cp /dev/null /etc/aliases.dir
cp /dev/null /etc/aliases.pag
routines preset the mode reasonably,
so this step can be skipped.
The actual path of this file
If you intend to install the frozen version of the configuration file
you should create the file /etc/sendmail.fc
This step may be safely skipped.
cp /dev/null /etc/sendmail.fc
chmod 644 /etc/sendmail.fc
In general, freeze files are not worth doing
unless your disks are much faster than your CPU;
this is seldom true any more.
It will be necessary to start up the sendmail daemon when your system reboots.
This daemon performs two functions:
it listens on the SMTP socket for connections
(to receive mail from a remote system)
and it processes the queue periodically
to insure that mail gets delivered when hosts come up.
Add the following lines to
in the area where it is starting up the daemons:
if [ \-f /usr/\*(SD/sendmail \-a \-f /etc/sendmail.cf ]; then
(cd /var/spool/mqueue; rm \-f [lnx]f*)
/usr/\*(SD/sendmail \-bd \-q30m &
echo \-n ' sendmail' >/dev/console
commands insure that all lock files have been removed;
extraneous lock files may be left around
if the system goes down in the middle of processing a message.
The line that actually invokes
causes it to listen on the SMTP port,
causes it to run the queue every half hour.
If you are not running a version of UNIX
that supports Berkeley TCP/IP,
.sh 3 "/usr/lib/sendmail.hf"
This is the help file used by the SMTP
cp lib/sendmail.hf /usr/lib
The actual path of this file
If you wish to collect statistics
you should create the file
cp /dev/null /etc/sendmail.st
chmod 666 /etc/sendmail.st
It is printed with the program
.q mailstats/mailstats.c.
The actual path of this file
.sh 3 "/usr/ucb/newaliases"
(i.e., will rebuild the alias database;
This should be a link to /usr/\*(SD/sendmail.
will print the contents of the mail queue;
This should be a link to /usr/\*(SD/sendmail.
.sh 1 "NORMAL OPERATIONS"
.sh 2 "Quick Configuration Startup"
A fast version of the configuration file
may be set up by using the
.q "frozen configuration" ).
data space after reading in the configuration file.
must be rebuilt manually every time
The frozen configuration file will be ignored
or if sendmail detects that it is out of date.
However, the heuristics are not strong
so this should not be trusted.
The system log is supported by the
Each line in the system log
the name of the machine that generated it
(for logging from several machines
over the local area network),
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.
only extremely strange situations are logged.
even the most mundane and uninteresting events
are recorded for posterity.
are usually for debugging purposes.
A complete description of the log levels
The mail queue should be processed transparently.
However, you may find that manual intervention is sometimes necessary.
if a major host is down for a period of time
the queue may become clogged.
Although sendmail ought to recover gracefully when the host comes up,
you may find performance unacceptably bad in the meantime.
.sh 3 "Printing the queue"
The contents of the queue can be printed
This will produce a listing of the queue id's,
the date the message entered the queue,
and the sender and recipients.
.sh 3 "Forcing the queue"
should run the queue automatically
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,
first checks to see if the job is locked.
If so, it ignores the job.
There is no attempt to insure that only one queue processor
since there is no guarantee that a job cannot take forever
does include heuristics to try to abort jobs
that are taking absurd amounts of time;
technically, this violates RFC 821, but is blessed by RFC 1123).
Due to the locking algorithm,
it is impossible for one job to freeze the entire queue.
an uncooperative recipient host
can accumulate many processes in your system.
there is no completely general way to solve this.
you may find that a major host going down
may create a prohibitively large queue.
spending an inordinate amount of time
This situation can be fixed by moving the queue to a temporary place
and creating a new queue.
The old queue can be run later when the offending host returns to service.
it is acceptable to move the entire queue directory:
mv mqueue omqueue; mkdir mqueue; chmod 700 mqueue
You should then kill the existing daemon
(since it will still be processing in the old queue directory)
To run the old mail queue,
run the following command:
/usr/\*(SD/sendmail \-oQ/var/spool/omqueue \-q
flag specifies an alternate queue directory
flag says to just run every job in the queue.
If you have a tendency toward voyeurism,
flag to watch what is going on.
When the queue is finally emptied,
you can remove the directory:
.sh 2 "The Alias Database"
The alias database exists in two forms.
The aliases are of the form
Only local names may be aliased;
eric@prep.ai.MIT.EDU: eric@CS.Berkeley.EDU
will not have the desired effect.
Aliases may be continued by starting any continuation lines
Blank lines and lines beginning with a sharp sign
The second form is processed by the
This form is in the files
actually uses to resolve aliases.
This technique is used to improve performance.
.sh 3 "Rebuilding the alias database"
The DBM version of the database
may be rebuilt explicitly by executing the command
This is equivalent to giving
option is specified in the configuration,
will rebuild the alias database automatically
Auto-rebuild can be dangerous
on heavily loaded machines
if it might take more than five minutes
there is a chance that several processes will start the rebuild process
.sh 3 "Potential problems"
There are a number of problems that can occur
process accessing the DBM version
while it is only partially built.
This can happen under two circumstances:
One process accesses the database
while another process is rebuilding it,
or the process rebuilding the database dies
(due to being killed or a system crash)
before completing the rebuild.
Sendmail has two 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.
at the end of the rebuild
it adds an alias of the form
(which is not normally legal).
Before sendmail will access the database,
it checks to insure that this entry exists\**.
option is required in the configuration
for this action to occur.
This should normally be specified
If an error occurs on sending to a certain address,
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.
unix-wizards: eric@ucbarpa, wnj@monet, nosuchuser,
owner-unix-wizards: eric@ucbarpa
to get the error that will occur
.sh 2 "User Information Database"
with the user information database
and you have specified one or more databases using the
the databases will be searched for a
If found, the mail will be sent to the specified address.
If the first token passed to user part of the
the at sign will be stripped off
and this step will be skipped.
.sh 2 "Per-User Forwarding (.forward Files)"
As an alternative to the alias database,
any user may put a file with the name
in his or her home directory.
redirects mail for that user
to the list of addresses listed in the .forward file.
For example, if the home directory for user
has a .forward file with contents:
then any mail arriving for
will be redirected to the specified accounts.
Actually, the configuration file defines a sequence of filenames to check.
By default, this is the user's .forward file,
but can be defined to be more generally using the
you will have to inform your user base of the change;
\&.forward is pretty well incorporated into the collective subconscious.
.sh 2 "Special Header Lines"
Several header lines have special interpretations
defined by the configuration file.
Others have interpretations built into
that cannot be changed without changing the code.
These builtins are described here.
.sh 3 "Return-Receipt-To:"
a message will be sent to any specified addresses
when the final delivery is complete,
when successfully delivered to a mailer with the
flag (local delivery) set in the mailer descriptor.
If errors occur anywhere during processing,
this header will cause error messages to go to
rather than to the sender.
This is intended for mailing lists.
If a message comes in with no recipients listed in the message
(in a To:, Cc:, or Bcc: line)
header line for any recipients it is aware of.
This is not put in as a standard recipient line
to warn any recipients that the list is not complete.
At least one recipient line is required under RFC 822.
The complete list of arguments to
is described in detail in Appendix A.
Some important arguments are described here.
The amount of time between forking a process
this can be relatively large,
since it will only be relevant
when a host that was down comes back up.
it should be relatively short,
since it defines the maximum amount of time that a message
If you allow incoming mail over an IPC connection,
you should have a daemon running.
This should be set by your
flag may be combined in one call:
/usr/\*(SD/sendmail \-bd \-q30m
.sh 2 "Forcing the Queue"
In some cases you may find that the queue has gotten clogged for some reason.
You can force a queue run
It is entertaining to use the
when this is done to watch what happens:
/usr/\*(SD/sendmail \-q \-v
There are a fairly large number of debug flags
Each debug flag has a number and a level,
where higher levels means to print out more information.
The convention is that levels greater than nine are
they print out so much information that you wouldn't normally
want to see them except for debugging that particular piece of code.
Debug flags are set using the
debug-flag: \fB\-d\fP debug-list
debug-list: debug-option [ , debug-option ]
debug-option: debug-range [ . debug-level ]
debug-range: integer | integer \- integer
where spaces are for reading ease only.
\-d12 Set flag 12 to level 1
\-d12.3 Set flag 12 to level 3
\-d3-17 Set flags 3 through 17 to level 1
\-d3-17.4 Set flags 3 through 17 to level 4
For a complete list of the available debug flags
you will have to look at the code
(they are too dynamic to keep this documentation up to date).
.sh 2 "Trying a Different Configuration File"
An alternative configuration file
can be specified using the
/usr/\*(SD/sendmail \-Ctest.cf
uses the configuration file
in the current directory.
.sh 2 "Changing the Values of Options"
Options can be overridden using the
/usr/\*(SD/sendmail \-oT2m
(timeout) option to two minutes
Some options have security implications.
Sendmail allows you to set these,
but refuses to root as root thereafter.
There are a number of configuration parameters
depending on the requirements of your site.
using an option in the configuration file.
Most of these options have appropriate defaults for most sites.
sites having very high mail loads may find they need to tune them
as appropriate for their mail load.
sites experiencing a large number of small messages,
many of which are delivered to many recipients,
may find that they need to adjust the parameters
dealing with queue priorities.
All time intervals are set
represents ten minutes, whereas
represents two and a half hours.
The full set of scales is:
specifies how often a sub-daemon will run the queue.
This is typically set to between fifteen minutes
It is possible to time out when reading the standard input
or when reading from a remote SMTP server.
this is not acceptable within the published protocols.
it might be appropriate to set it to something large
This will reduce the chance of large numbers of idle daemons
piling up on your system.
This timeout is set using the
option in the configuration file.
recommends that this option be set to five minutes.
was designed to the RFC822 protocols,
which did not specify read timeouts;
does not guarantee to reply to messages promptly.
command specifying a mailing list
will expand and verify the entire list;
a large list on a slow system
may take more than five minutes\**.
\**This verification includes looking up every address
this involves network delays,
and can in some cases can be considerable.
I recommend a two hour timeout \*-
since this failure is rare,
a long timeout is not onerous
and may ultimately help reduce network load.
The timeout for a user SMTP process
is hard-wired to five minutes.
After sitting in the queue for a few days,
This is to insure that at least the sender is aware
of the inability to send a message.
The timeout is typically set to three days.
This timeout is set using the
option in the configuration file.
The time of submission is set in the queue,
rather than the amount of time left until timeout.
As a result, you can flush messages that have been hanging
with a short message timeout.
/usr/\*(SD/sendmail \-oT1d \-q
and flush anything that is one day old.
Since this option is global,
know how long another host outside your domain will be down,
a three day timeout is recommended.
This allows a recipient to fix the problem even if it occurs
at the beginning of a weekend.
.sh 2 "Forking During Queue Runs"
will fork before each individual message
from consuming large amounts of memory,
so it may be useful in memory-poor environments.
will keep track of hosts that are down during a queue run,
which can improve performance dramatically.
can not use connection caching.
Every message is assigned a priority when it is first instantiated,
consisting of the message size (in bytes)
offset by the message class times the
and the number of recipients times the
.q "work recipient factor."
The priority is used to order the queue.
Higher numbers for the priority mean that the message will be processed later
The message size is included so that large messages are penalized
relative to small messages.
The message class allows users to send
the value of this field is looked up in the
lines of the configuration file.
Since the number of recipients affects the amount of load a message presents
this is also included into the priority.
The recipient and class factors
can be set in the configuration file using the
They default to 30000 (for the recipient factor)
pri = size - (class times bold z) + (nrcpt times bold y)
(Remember, higher values for this parameter actually mean
that the job will be treated with lower priority.)
The priority of a job can also be adjusted each time it is processed
(that is, each time an attempt is made to deliver it)
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.
option defaults to 90000.
can be asked to queue (but not deliver)
mail if the system load average gets too high
When the load average exceeds the value of the
the delivery mode is set to
divided by the difference in the current load average and the
exceeds the priority of the message \(em
that is, the message is queued iff:
pri > bold q over { LA - bold x + 1 }
option defaults to 200000,
so each point of load average is worth 200000
option defines a load average at which sendmail will refuse
to accept network connections.
(including incoming UUCP mail)
There are a number of delivery modes that
specify how quickly mail will be delivered.
i deliver interactively (synchronously)
b deliver in background (asynchronously)
q queue only (don't deliver)
passes the maximum amount of information to the sender,
but is hardly ever necessary.
puts the minimum load on your machine,
but means that delivery may be delayed for up to the queue interval.
is probably a good compromise.
However, this mode can cause large numbers of processes
if you have a mailer that takes a long time to deliver a message.
The level of logging can be set for sendmail.
The default using a standard configuration table is level 9.
The levels are as follows:
Message collections and failed deliveries.
(due to a host being down, etc.).
Unusual but benign incidents,
trying to process a locked queue file.
Log internal queue id to external message id mappings.
This can be useful for tracing a message
as it travels between several hosts.
Also logs any VRFY or EXPN requests.
Logs attempts to run locked queue files.
but can be useful to note if your queue appears to be clogged.
Several messages that are basically only of interest
Verbose information regarding the queue.
.sh 2 "Wildcard MX Records"
is looking up host names from the name server,
option will ask the name server to use a querytype of
This finds CNAME, A, and MX records,
and causes the local name server to cache all records it finds,
thus improving performance.
However, if your site has wildcard MX records, this can cause problems.
For example, suppose your site has a record directing
.q "gateway.HiTech.COM" .
When the resolver looks for (e.g.)
.q "mammoth.Berkeley.EDU" ,
it starts by appending the local domain name (in this case,
.q "mammoth.Berkeley.EDU.HiTech.COM"
\*- which of course matches
If you do not have wildcard MX records in your domain,
option to get better performance.
There are a number of files
that may have a number of modes.
The modes depend on what functionality you want
and the level of security you require.
.sh 3 "To suid or not to suid?"
At the point where it is about to
it checks to see if the userid is zero;
it resets the userid and groupid to a default
for mailers that are trusted
and must be called as root.)
this will cause mail processing
rather than to the user sending the mail.
.sh 3 "Should my alias database be writable?"
we have the alias database
While this is not as flexible as if the database
were more 666, it avoids potential security problems
with a globally writable database.
is represented by the two files
if you are running with the new Berkeley database primitives).
The mode on these files should match the mode
users will be unable to reflect their desired changes
through to the actual database.
and the DBM files are writable,
a slightly sophisticated user
can arrange to steal mail anyway.
If your DBM files are not writable by the world
or you do not have auto-rebuild enabled
then you must be careful to reconstruct the alias database
each time you change the text version:
If this step is ignored or forgotten
any intended changes will also be ignored or forgotten.
.sh 2 "Connection Caching"
When processing the queue,
will try to keep the last few open connections open
to avoid startup and shutdown costs.
This only applies to IPC connections.
When trying to open a connection
the cache is first searched.
If an open connection is found, it is probed to see if it is still active
It is not an error if this fails;
instead, the connection is closed and reopened.
Two parameters control the connection cache.
option defines the number of simultaneous open connections
connections will be closed as quickly as possible.
This should be set as appropriate for your system size;
it will limit the amount of system resources that
will use during queue runs.
option specifies the maximum time that any cached connection
will be permitted to idle.
When the idle time exceeds this value
the connection is closed.
This number should be small
to prevent you from grabbing too many resources
The default is five minutes.
.sh 2 "Name Server Access"
If your system supports the name server,
then the probability is that
will be using it regardless of how you configure sendmail.
However, if you have nameserver support
message when it tries to connect to the name server
or by trying to look up the MX records).
will interpret this to mean a temporary failure;
otherwise, it ignores the name server data.
If your name server is running properly,
the setting of this option is not relevant;
however, it is important that it be set properly
to make error handling work properly.
This option also allows you to tweak name server options.
The command line takes a series of flags as documented in
Each can be preceded by an optional `+' or `\(mi'.
OITrue +AAONLY \(miDNSRCH
turns on the AAONLY (accept authoritative answers only)
and turns off the DNSRCH (search the domain path) options.
Most resolver libraries default DNSRCH, DEFNAMES, and RECURSE
flags on and all others off.
Note the use of the initial ``True'' \*-
this is for compatibility with previous versions of sendmail,
but is not otherwise necessary.
turn DNSRCH and DEFNAMES off when doing delivery lookups,
but leave them on everywhere else.
ignores them when doing canonification lookups
(that is, when using $[ ... $]),
and always does the search.
If you don't want to do automatic name extension,
The search rules for $[ ... $] are somewhat different than usual.
If the name (that is, the ``...'')
has at least one dot, it always tries the unmodified name first.
If that fails, it tries the reduced search path,
and lastly tries the unmodified name
(but only for names without a dot,
since names with a dot have already been tried).
This allows names such as
to match the site in Czechoslovakia
rather than the site in your local Computer Science department.
.sh 2 "Moving the Per-User Forward Files"
Some sites mount each user's home directory
from a local disk on their workstation,
so that local access is fast.
However, the result is that .forward file lookups are slow.
mail can even be delivered on machines inappropriately
because of a file server being down.
The performance can be especially bad if you run the automounter.
option allows you to set a path of forward files.
For example, the config file line
OJ/var/forward/$u:$z/.forward
would first look for a file with the same name as the user's login
if that is not found (or is inaccessible)
in the user's home directory is searched.
A truly perverse site could also search by sender
If you create a directory such as /var/forward,
(that is, the sticky bit should be set).
Users should create the files mode 644.
.sh 1 "THE WHOLE SCOOP ON THE CONFIGURATION FILE"
This section describes the configuration file
including hints on how to write one of your own
There is one point that should be made clear immediately:
the syntax of the configuration file
is designed to be reasonably easy to parse,
since this is done every time
rather than easy for a human to read or write.
configuration-file compiler.
An overview of the configuration file
followed by details of the semantics.
.sh 2 "Configuration File Lines"
The configuration file is organized as a series of lines,
each of which begins with a single character
defining the semantics for the rest of the line.
Lines beginning with a space or a tab
(although the semantics are not well defined in many places).
Blank lines and lines beginning with a sharp symbol
.sh 3 "R and S \*- rewriting rules"
The core of address parsing
These are an ordered production system.
scans through the set of rewriting rules
looking for a match on the left hand side
the address is replaced by the right hand side
There are several sets of rewriting rules.
Some of the rewriting sets are used internally
and must have specific semantics.
do not have specifically assigned semantics,
and may be referenced by the mailer definitions
or by other rewriting sets.
The syntax of these two commands are:
Sets the current ruleset being collected to
If you begin a ruleset more than once
it deletes the old definition.
by at least one tab character;
there may be embedded spaces
is a pattern that is applied to the input.
the input is rewritten to the
.sh 4 "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.
.ta \w'\fB$=\fP\fIx\fP 'u
\fB$*\fP Match zero or more tokens
\fB$+\fP Match one or more tokens
\fB$\-\fP Match exactly one token
\fB$=\fP\fIx\fP Match any token in class \fIx\fP
\fB$~\fP\fIx\fP Match any token not in class \fIx\fP
they are assigned to the symbol
for replacement on the right hand side,
the rule will match, and the values passed to the RHS will be:
.sh 4 "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.
\fB$\fP\fIn\fP Substitute indefinite token \fIn\fP from LHS
\fB$[\fP\fIname\fP\fB$]\fP Canonicalize \fIname\fP
\fB$(\fP\fImap key\fP \fB$@\fP\fIarguments\fP \fB$:\fP\fIdefault\fP \fB$)\fP
Generalized keyed mapping function
\fB$>\fP\fIn\fP \*(lqCall\*(rq ruleset \fIn\fP
\fB$#\fP\fImailer\fP Resolve to \fImailer\fP
\fB$@\fP\fIhost\fP Specify \fIhost\fP
\fB$:\fP\fIuser\fP Specify \fIuser\fP
syntax substitutes the corresponding value from a
A host name enclosed between
routines and replaced by the canonical name.
.q vangogh.CS.Berkeley.EDU.
syntax is a more general form of lookup;
it uses a named map instead of an implicit map.
If no lookup is found, the indicted
if no default is specified and no lookup matches,
the value is left unchanged.
causes the remainder of the line to be substituted as usual
and then passed as the argument to ruleset
The final value of ruleset
the substitution for this rule.
It causes evaluation of the ruleset to terminate immediately,
and signals to sendmail that the address has completely resolved.
\fB$#\fP\fImailer\fP\fB$@\fP\fIhost\fP\fB$:\fP\fIuser\fP
3-tuple necessary to direct the mailer.
the host part may be omitted.
A RHS may also be preceded by a
prefix causes the ruleset to return with the remainder of the RHS
prefix causes the rule to terminate immediately,
but the ruleset to continue;
this can be used to avoid continued application of a rule.
The prefix is stripped before continuing.
passes that to ruleset seven,
is necessary to avoid an infinite loop.
Substitution occurs in the order described,
parameters from the LHS are substituted,
hostnames are canonicalized,
..sh 3 "D \*- define macro"
Macros are named with a single character.
These may be selected from the entire ASCII set,
should be selected from the set of upper case letters only.
The syntax for macro definitions is:
is the value it should have.
is the name of the macro to be interpolated.
lower case letters are reserved to have
used to pass information in or out of sendmail,
and some special characters are reserved to
provide conditionals, etc.
Conditionals can be specified using the syntax:
be defined to transmit information into
j The \*(lqofficial\*(rq domain name for this site
l The format of the UNIX from line
n The name of the daemon (for error messages)
o The set of "operators" in addresses
q default format of sender address
macro is printed out when SMTP starts up.
The first word must be the
should be in RFC821 format.
macros can be considered constants
except under terribly unusual circumstances.
macro consists of a list of characters
which will be considered tokens
and which will separate tokens
would be scanned as three tokens:
macro specifies how an address should appear in a message
For example, on our system these definitions are:
De$j Sendmail $v ready at $b
An acceptable alternative for the
These correspond to the following two formats:
eric@CS.Berkeley.EDU (Eric Allman)
Eric Allman <eric@CS.Berkeley.EDU>
Some macros are defined by
for interpolation into argv's for mailers
a The origination date in RFC 822 format
b The current date in RFC 822 format
d The date in UNIX (ctime) format
f The sender (from) address
g The sender address relative to the recipient
m The domain part of the \fIgethostname\fP return value
r Protocol used to receive the message
t A numeric representation of the current time
v The version number of sendmail
w The hostname of this site
x The full name of the sender
z The home directory of the recipient
< The return-path (sender in envelope) relative to recipient
There are three types of dates that can be used.
macros are in RFC 822 format;
is the time as extracted from the
is the current date and time
line is found in the incoming message,
is set to the current time also.
macro is equivalent to the
macro is the id of the sender
as originally determined;
when mailing to a specific host
macro is set to the address of the sender
relative to the recipient.
macro is identical to the
macro except that it uses the envelope sender
instead of the From: address in the body of the message.
macro is set to the full name of the sender.
This can be determined in several ways.
It can be passed as flag to
The second choice is the value of the
line in the header if it exists,
and the third choice is the comment field
and if the message is being originated locally,
the full name is looked up in the
macros get set to the host, user, and home directory
The first two are set from the
part of the rewriting rules, respectively.
macros are used to create unique strings
macro is set to the queue id on this host;
if put into the timestamp line
it can be extremely useful for tracking messages.
macro is set to be the version number of
this is normally put in timestamps
and has been proven extremely useful for debugging.
macro is set to the name of this host
i.e., the number of times this message has been processed.
or by counting the timestamps in the message.
fields are set to the protocol used to communicate with sendmail
and the sending hostname.
.sh 4 "Semantics of rewriting rule sets"
There are five rewriting sets
that have specific semantics.
These are related as depicted by figure 2.
-->| 0 |-->resolved address
+---+ / +---+ / +---+ +---+ \e +---+
addr-->| 3 |-->| D |-- --->| 4 |-->msg
+---+ +---+ \e +---+ +---+ / +---+
BoxD: box "D"; line; L1: Here
C1: arrow; box "1"; arrow; box "S"; line; E1: Here
move to C1 down 0.5; right
C2: arrow; box "2"; arrow; box "R"; line; E2: Here
] with .w at L1 + (0.5, 0)
L4: arrow; box "4"; arrow; box invis "msg"
move to BoxD.n up 0.6; right
arrow; box invis "resolved address" width 1.3
line from 1/3 of the way between A1 and BoxD.w to Box0
Figure 2 \*- Rewriting set semantics
D \*- sender domain addition
S \*- mailer-specific sender rewriting
R \*- mailer-specific recipient rewriting
should turn the address into
This form should have the basic syntax:
local-part@host-domain-spec
flag is set in the mailer definition
before doing anything with any address.
is applied after ruleset three
to addresses that are going to actually specify recipients.
.i "{mailer, host, user}"
must be defined in the mailer definitions
from the configuration file.
for use in the argv expansion of the specified mailer.
are applied to all sender and recipient addresses respectively.
They are applied before any specification
in the mailer definition.
Ruleset four is applied to all addresses
to translate internal to external form.
.sh 3 "C and F \*- define classes"
Classes of words may be defined
to match on the left hand side of rewriting rules,
is a sequence of characters that do not contain characters
a class of all local names for this site
so that attempts to send to oneself
These can either be defined directly in the configuration file
or read in from another file.
Classes may be given names
from the set of upper case letters.
Lower case letters and special characters
are reserved for system use.
The first form defines the class
to match any of the named words.
It is permissible to split them among multiple lines;
for example, the two forms:
reads the elements of the class
is set to be the set of all names
This can be used to match local hostnames.
.sh 3 "M \*- define mailer"
Programs and interfaces to mailers
are defined in this line.
is the name of the mailer
pairs define attributes of the mailer.
Path The pathname of the mailer
Flags Special flags for this mailer
Sender A rewriting set for sender addresses
Recipient A rewriting set for recipient addresses
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
Linelimit The maximum line length in the message body
Only the first character of the field name is checked.
The following flags may be set in the mailer description.
Any other flags may be used freely
to conditionally assign headers to messages
destined for particular mailers.
from a mailer with this flag set,
any addresses in the header that do not have an at sign
after being rewritten by ruleset three
This allows mail with headers of the form:
To: userb@hostb, userc@hosta
This mailer is expensive to connect to,
so try to avoid connecting normally;
any necessary connection will occur during a queue run.
Escape lines beginning with
in the message with a `>' sign.
but only if this is a network forward operation
the mailer will give an error
does not have special permissions).
Upper case should be preserved in host names
This mailer will be speaking SMTP
as such it can use special protocol features.
This option is not required
if this option is omitted the transmission will still operate successfully,
although perhaps not as efficiently as possible).
final delivery will be performed).
Limit the line lengths as specified in RFC821.
This deprecated option should be replaced by the
For historic reasons, the
This mailer can send to multiple users
part of the mailer definition,
that field will be repeated as necessary
for all qualifying users.
Do not insert a UNIX-style
line on the front of the message.
Use the return-path in the SMTP
rather than just the return address;
although this is required in RFC821,
many hosts do not process return paths properly.
Strip quote characters off of the address
before calling the mailer.
before calling the mailer.
This would be used in a secure environment
This could be used to avoid forged addresses.
This flag is suppressed if given from an
(e.g, a user's mail.cf file).
Upper case should be preserved in user names
This mailer wants Unix-style
lines with the ugly UUCP-style
This mailer want to use the hidden dot algorithm
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.
Strip all output to seven bits.
This is the default if the
Note that setting this is not
sufficient to get full eight bit data passed through
The mailer with the special name
can be used to generate a user error.
The (optional) host field is an exit status to be returned,
and the user field is a message to be printed.
The exit status may be numeric or one of the values
USAGE, NOUSER, NOHOST, UNAVAILABLE, SOFTWARE, TEMPFAIL, PROTOCOL, or CONFIG
to return the corresponding EX_ exit code.
$#error $@ NOHOST $: Host unknown in this domain
will cause the specified error to be generated
exit status to be returned
This mailer is only functional in ruleset zero.
be defined in every configuration file.
This is used to deliver local mail,
and is treated specially in several ways.
Additionally, three other mailers named
may be defined to tune the delivery of messages to programs,
and :include: lists respectively.
Mprog, P=/bin/sh, F=lsD, A=sh \-c $u
.sh 3 "H \*- define header"
The format of the header lines that sendmail inserts into the message
The syntax of this line is:
Continuation lines in this spec
are reflected directly into the outgoing message.
is macro expanded before insertion into the message.
(surrounded by question marks)
at least one of the specified flags
must be stated in the mailer definition
for this header to be automatically output.
If one of these headers is in the input
it is reflected to the output
regardless of these flags.
Some headers have special semantics
that will be described below.
can be set from a configuration file.
Options are represented by single characters.
The syntax of this line is:
may be a string, an integer,
The options supported are:
entry to exist in the alias database
in the current directory.
Set the blank substitution character to
Unquoted spaces in addresses are replaced by this character.
Defaults to space (i.e., no change is made).
If an outgoing mailer is marked as being expensive,
don't connect immediately.
This requires that queueing be compiled in,
since it will depend on a queue run process to
Checkpoints the queue every
If your system crashes during delivery to a large list,
this prevents retransmission to any but the last
i Deliver interactively (synchronously)
b Deliver in background (asynchronously)
q Just queue the message (deliver during queue run)
rebuild the alias database if necessary and possible.
If this option is not set,
will never rebuild the alias database
unless explicitly requested
Dispose of errors using mode
p Print error messages (default)
q No messages, just give exit status
w Write back errors (mail if user not logged in)
e Mail back errors and give zero exit stat always
Prepend error messages with the indicated message.
If it begins with a slash,
it is assumed to be the pathname of a file
containing a message (this is the recommended setting).
Otherwise, it is a literal message.
The error file might contain the name, email address, and/or phone number
of a local postmaster who could provide assistance
If the option is missing or null,
or if it names a file which does not exist or which is not readable,
lines at the front of headers.
Normally they are assumed redundant
The file mode for queue files.
Allow fuzzy matching on the GECOS field.
and the usual user name lookups fail
(that is, there is no alias with this name and a
sequentially search the password file
for a matching entry in the GECOS field.
This also requires that MATCHGECOS
be turned on during compilation.
This option is not recommended.
Messages that have been processed more than
times are assumed to be in a loop and are rejected.
Ignore dots in incoming messages.
Insist that the BIND name server be running
If this is not set and the name server is not running,
file will be considered complete.
In general, you do want to set this option
file does not include all hosts known to you
or if you are using the MX (mail forwarding) feature of the BIND name server.
The name server will still be consulted
even if this option is not set, but
will feel free to resort to reading
if the name server is not available.
set this option if you do not run the name server.
Set the path for searching for users' .forward files.
Some sites that use the automounter may prefer to change this to
to search a file with the same name as the user in a system directory.
It can also be set to a sequence of paths separated by colons;
stops at the first file it can successfully and safely open.
.q /var/forward/$u:$z/.forward
will search first in /var/forward/\c
(but only if the first file does not exist).
The maximum number of open connections that will be cached at a time.
This delays closing the the current connection until
either this invocation of sendmail needs to connect to another host
Setting it to zero defaults to the old behavior,
that is, connections are closed immediately.
The maximum amount of time a cached connection will be permitted to idle
If this time is exceeded,
the connection is immediately closed.
This value should be small (on the order of ten minutes).
uses a cached connection,
it always sends a NOOP (no operation) command
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
The default is five minutes.
Set the default log level to
even if I am in an alias expansion.
This is intended only for use from the command line.
Assume that the headers may be in old format,
if any recipient address contains a comma, parenthesis,
it will be assumed that commas already exist.
only commas delimit names.
Headers are always output with commas between the names.
copies of error messages will be sent to the named
Since most errors are user problems,
this is probably not a good idea on large sites,
and arguably contains all sorts of privacy violations,
but it seems to be popular with certain operating systems vendors.
as the multiplier in the map function
to decide when to just queue up jobs rather than run them.
This value is divided by the difference between the current load average
and the load average limit
to determine the maximum message priority
Be super-safe when running things,
always instantiate the queue file,
even if you are going to attempt immediate delivery.
always instantiates the queue file
before returning control the the client
Log statistics in the named
Set the local time zone name to
this is only used under version six.
messages that have not been successfully sent
will be returned to the sender.
Set the default userid for mailers to
flag in the mailer definition
The user database specification.
Asserts that this domain does not have wildcard MX records
in the name server database.
names that are directed outward
and forward them back to your own site.
If there are no wildcards matching your domain,
this option will reduce name server load
When the system load average exceeds
(i.e., don't try to send them).
When the system load average exceeds
refuse incoming SMTP connections.
is added to the priority (thus
i.e., this value penalizes jobs with large numbers of recipients.
deliver each job that is run from the queue in a separate process.
Use this option if you are short of memory,
since the default tends to consume considerable amounts of memory
while the queue is being processed.
is multiplied by the message class
(determined by the Precedence: field in the user header
lines in the configuration file)
and subtracted from the priority.
Thus, messages with a higher Priority: will be favored.
every time a job is processed.
each time a job is processed,
its priority will be decreased by the indicated value.
In most environments this should be positive,
since hosts that are down are all too often down for a long time.
Preserve eight bits of data in the body on input.
Normally the input is stripped to seven bits as per RFC822.
All options can be specified on the command line using the
to relinquish its setuid permissions.
The options that will not cause this are
d, e, E, i, L, m, o, r, s, v, C, and 8.
Also, M (define macro) when defining the r or s macros
.sh 3 "T \*- define trusted users"
are those users who are permitted
to override the sender address
but on some users it may be convenient
to extend this list to include other users,
The syntax of this line is:
There may be more than one of these lines.
.sh 3 "P \*- precedence definitions"
field may be defined using the
The syntax of this field is:
\fBP\fP\fIname\fP\fB=\fP\fInum\fP
the message class is set to
Higher numbers mean higher precedence.
have the special property
that if an error occurs during processing
the body of the message will not be returned;
this is expected to be used for
mail such as through mailing lists.
The default precedence is zero.
our list of precedences is:
.sh 3 "V \*- configuration version level"
To provide compatibility with old configuration files,
line has been added to define some very basic semantics
of the configuration file.
These are not intended to be long term supports;
rather, they describe compatibility features
which will probably be removed in future releases.
configuration files are defined as level one.
Level two files make the following changes:
Host name canonification ($[ ... $])
appends a dot if the name is recognized;
this gives the config file a way of finding out if anything matched.
(Actually, this just initializes the
flag \*- you can reset it to anything you prefer
by declaring the map explicitly.)
Default host name extension is consistent throughout processing;
level one configurations turned off domain extension
(that is, adding the local domain name)
during certain points in processing.
Level two configurations are expected to include a trailing dot
to indicate that the name is already canonical.
Local names that are not aliases
are passed through a new distinguished ruleset five;
this can be used to append a local relay.
This behaviour can be prevented by resolving the local name
That is, something that resolves to a local mailer and a user name of
will be passed through ruleset five,
will have the `@' stripped,
will not be passed through ruleset five,
but will otherwise be treated the same as the prior example.
The expectation is that this might be used to implement a policy
was handled by a central hub,
allow # initiated comments on all lines.
Exceptions are backslash escaped # marks
.sh 3 "K \*- key file declaration"
Special maps can be defined using the line:
Kmapname mapclass arguments
is the handle by which this map is referenced in the rewriting rules.
is the name of a type of map;
these are compiled in to sendmail.
are interpreted depending on the class;
there would be a single argument naming the file containing the map.
Maps are referenced using the syntax:
$( \fImap\fP \fIkey\fP $@ \fIarguments\fP $: \fIdefault\fP $)
where either or both of the
may appear more than once.
are passed to the appropriate mapping function.
If it returns a value, it replaces the input.
If it does not return a value and the
Otherwise, the input is unchanged.
During replacement of either a map value or default
is replaced by the corresponding
is always the original pattern.
R$- ! $+ $: $(uucp $1 $@ $2 $: %1 @ %0 . UUCP $)
Looks up the UUCP name in a (user defined) UUCP map;
if not found it turns it into
The database might contain records like:
The built in map with both name and class
is the host name canonicalization lookup.
There are four predefined database lookup classes:
The first requires that sendmail be compiled with the
the second two require the
and the third requires that sendmail be compiled with NIS support.
All four accept as arguments the some optional flags
and a filename (or a mapname for NIS).
Indicates that this map is optional \*- that is,
and sendmail will behave as if the map existed but was empty.
Normally sendmail does not include the trailing null byte
on a string as part of the key.
If this flag is indicated,
This is for compatibility with some methods of building the maps.
map appends a dot on successful matches.
instead of the default domain.
Fold upper to lower case before looking up the key.
Match only (without replacing the value).
If you only care about the existence of a key and not the value
(as you might when searching the NIS map
this flag prevents the map from substituting the value.
The \-a argument is still appended on a match,
and the default is still taken if the match fails.
can be used to build any of the three database-oriented maps.
It takes the following flags:
Fold upper to lower case in the map.
Include null bytes in keys.
Append to an existing (old) file.
Allow replacement of existing keys;
normally, re-inserting an existing key is an error.
New classes can be added in the routine
.sh 2 "Building a Configuration File From Scratch"
Building a configuration table from scratch is an extremely difficult job.
it is almost never necessary to do so;
nearly every situation that may come up
may be resolved by changing an existing table.
it is critical that you understand what it is that you are trying to do
and come up with a philosophy for the configuration table.
This section is intended to explain what the real purpose
of a configuration table is
and to give you some ideas
for what your philosophy might be.
.sh 3 "What you are trying to do"
The configuration table has three major purposes.
is to set up the environment for
This involves setting the options,
defining a few critical macros,
Since these are described in other places,
we will not go into more detail here.
The second purpose is to rewrite addresses in the message.
This should typically be done in two phases.
The first phase maps addresses in any format
This should be done in ruleset three.
The second phase maps this canonical form
into the syntax appropriate for the receiving mailer.
does this in three subphases.
are applied to all sender and recipient addresses respectively.
you may specify per-mailer rulesets
for both sender and recipient addresses;
this allows mailer-specific customization.
ruleset four is applied to do any default conversion
is to map addresses into the actual set of instructions
necessary to get the message delivered.
Ruleset zero must resolve to the internal form,
which is in turn used as a pointer to a mailer descriptor.
The mailer descriptor describes the interface requirements
The particular philosophy you choose will depend heavily
on the size and structure of your organization.
I will present a few possible philosophies here.
One general point applies to all of these philosophies:
it is almost always a mistake
to try to do full name resolution.
if you are trying to get names of the form
it does not pay to route them to
.q xyzvax!decvax!ucbvax!c70:user@host
since you then depend on several links not under your control.
The best approach to this problem
worry about it from there.
just get the message closer to the destination,
rather than determining the full path.
.sh 4 "Large site, many hosts \*- minimum information"
Berkeley is an example of a large site,
i.e., more than two or three hosts
and multiple mail connections.
We have decided that the only reasonable philosophy
is to designate one host as the guru for our site.
It must be able to resolve any piece of mail it receives.
The other sites should have the minimum amount of information
any information they do have
should be hints rather than solid information.
a typical site on our local ether network is
When monet receives mail for delivery,
it checks whether it knows
that the destination host is directly reachable;
if so, mail is sent to that host.
If it receives mail for any unknown host,
it just passes it directly to
Ucbvax may determine that the host name is illegal
or may be able to do delivery.
However, it is important to note that when a new mail connection is added,
be updated if convenient,
but this is not critical.
This picture is slightly muddied
due to network connections that are not actually located
some UUCP connections are currently on
the information is hidden totally between ucbvax and ucbarpa.
Mail going from monet to a UUCP host
is transferred via the ethernet
then via the ethernet from ucbvax to ucbarpa,
and then is submitted to UUCP.
Although this involves some extra hops,
we feel this is an acceptable tradeoff.
An interesting point is that it would be possible
to send appropriate UUCP mail directly to ucbarpa
if the load got too high;
if monet failed to note a host as connected to ucbarpa
it would go via ucbvax as before,
and if monet incorrectly sent a message to ucbarpa
it would still be sent by ucbarpa
The only problem that can occur is loops,
if ucbarpa thought that ucbvax had the UUCP connection
happen to the master host first.
This philosophy results as much from the need
to have a single source for the configuration files
Maintaining more than three separate tables by hand
is essentially an impossible job.
.sh 4 "Small site \*- complete information"
(two or three hosts and few external connections)
may find it more reasonable to have complete information
This would require that each host
know exactly where each network connection is,
possibly including the names of each host on that network.
As long as the site remains small
and the the configuration remains relatively static,
the update problem will probably not be too great.
This is in some sense the trivial case.
The only major issue is trying to insure that you don't
have to know too much about your environment.
if you have a UUCP connection
you might find it useful to know about the names of hosts
connected directly to you,
but this is really not necessary
since this may be determined from the syntax.
The canonical form you use
should almost certainly be as specified in
Copies of these RFC's are included on the
describes the format of the mail message itself.
follows this RFC closely,
to the extent that many of the standards described in this document
can not be changed without changing the code.
the following characters have special interpretations:
Any attempt to use these characters for other than their RFC822
purpose in addresses is probably doomed to disaster.
describes the specifics of the domain-based addressing.
This is touched on in RFC822 as well.
Essentially each host is given a name
which is a right-to-left dot qualified pseudo-path
from a distinguished root.
The elements of the path need not be physical hosts;
the domain is logical rather than physical.
reading from right to left,
comprising educational institutions,
is a logical domain name,
represents the Computer Center,
(in this case a strictly logical entity),
is a host in the Computer Center.
Beware when reading RFC819
that there are a number of errors in it.
Once you have decided on a philosophy,
it is worth examining the available configuration tables
to decide if any of them are close enough
Even under the worst of conditions,
there is a fair amount of boiler plate that can be collected safely.
The next step is to build ruleset three.
This will be the hardest part of the job.
Beware of doing too much to the address in this ruleset,
since anything you do will reflect through
stripping of local domains is best deferred,
since this can leave you with addresses with no domain spec at all.
likes to append the sending domain to addresses with no domain,
this can change the semantics of addresses.
fully qualifying domains in this ruleset.
Although technically legal,
this can lead to unpleasantly and unnecessarily long addresses
The Berkeley configuration files
to qualify domain names and strip local domains.
This is called from ruleset zero
to get all addresses into a cleaner form.
Once you have ruleset three finished,
the other rulesets should be relatively trivial.
examine the supplied configuration tables.
.sh 3 "Testing the rewriting rules \*- the \-bt flag"
When you build a configuration table,
you can do a certain amount of testing
which would read the configuration file
you enter lines of the form:
is the rewriting set you want to use
is an address to apply the set to.
Test mode shows you the steps it takes
finally showing you the address it ends up with.
You may use a comma separated list of rwsets
for sequential application of rules to an input;
ruleset three is always applied first.
first applies ruleset three to the input
Ruleset one is then applied to the output of ruleset three,
followed similarly by rulesets twenty-one and four.
flag to turn on more debugging.
turns on an incredible amount of information;
is probably going to print out several pages worth of information.
.sh 3 "Building mailer descriptions"
To add an outgoing mailer to your mail system,
you will have to define the characteristics of the mailer.
Each mailer must have an internal name.
The pathname of the mailer must be given in the P field.
If this mailer should be accessed via an IPC connection,
The F field defines the mailer flags.
flag to pass the name of the sender as a
These flags are only passed if they were passed to
so that mailers that give errors under some circumstances
If the mailer is not picky
If the mailer must be called as
this will not reset the userid
before calling the mailer\**.
must be running setuid to root
(i.e., will perform final delivery
rather than another network hop)
(backslashes and " marks)
can be stripped from addresses if the
If the mailer is capable of sending to more than one user
then the argv template containing
will be repeated for each unique user
flag will mark the mailer as being
configuration option must be given
for this to be effective.
This flag applies to the mailer that the message is received from,
rather than the mailer being sent to;
the domain spec of the sender
and is appended to any addresses in the message
that do not already contain a domain spec.
To: wnj@monet, mckusick@ucbarpa
flag is defined in the mailer corresponding to
Other flags are described
The S and R fields in the mailer description
are per-mailer rewriting sets
to be applied to sender and recipient addresses
These are applied after the sending domain is appended
and the general rewriting sets
but before the output rewrite
A typical use is to append the current domain
to addresses that do not already have a domain.
depending on the domain it is being shipped into.
These sets can also be used
to do special purpose output rewriting
in cooperation with ruleset four.
The E field defines the string to use
as an end-of-line indication.
A string containing only newline is the default.
The usual backslash escapes
an argv template is given as the E field.
It may have embedded spaces.
If there is no argv with a
If the pathname for this mailer is
is the optional port number
.ta \w'Mlocal, 'u +\w'P=/bin/mail, 'u +\w'F=rlsm, 'u +\w'S=10, 'u +\w'R=20, 'u
Mlocal, P=/bin/mail, F=rlsm S=10, R=20, A=mail \-d $u
Mether, P=[IPC], F=meC, S=11, R=21, A=IPC $h, M=100000
specifies a mailer to do local delivery
and a mailer for ethernet delivery.
quotes should be stripped from addresses,
and multiple users can be delivered at once;
should be applied to sender addresses in the message
should be applied to recipient addresses;
the argv to send to a message will be the word
and words containing the name of the receiving user.
it will be between the words
The second mailer is called
it should be connected to via an IPC connection,
it can handle multiple users at once,
connections should be deferred,
and any domain from the sender address
should be appended to any receiver name
sender addresses should be processed by ruleset eleven
and recipient addresses by ruleset twenty-one.
There is a 100,000 byte limit on messages passed through this mailer.
.sh 2 "The User Database"
If you have a version of sendmail with the user database package
the handling of sender and recipient addresses
The location of this database is controlled with the
.sh 3 "Structure of the user database"
The database is a sorted (BTree-based) structure.
User records are stored with the key:
\fIuser-name\fP\fB:\fP\fIfield-name\fP
The sorted database format ensures that user records are clustered together.
Meta-information is always stored with a leading colon.
Field names define both the syntax and semantics of the value.
The delivery address for this user.
There may be multiple values of this record.
mailing lists will have one
record for each user on the list.
The outgoing mailname for this user.
there should be an appropriate
record for that name to allow return mail.
The full name of the user.
The office address for this user.
The office phone number for this user.
The office FAX number for this user.
The home address for this user.
The home phone number for this user.
The home FAX number for this user.
A (short) description of the project this person is affiliated with.
In the University this is often just the name of their graduate advisor.
A pointer to a file from which plan information can be gathered.
only a few of these fields are actually being used by sendmail:
program that uses the other fields is planned.
.sh 3 "User database semantics"
When the rewriting rules submit an address to the local mailer,
the user name is passed through the alias file.
If no alias is found (or if the alias points back to the same address),
is then used as a key in the user database.
If no match occurs (or if the maildrop points at the same address),
If the first token of the user name returned by ruleset 0
sign, the user database lookup is skipped.
The intent is that the user database will act as a set of defaults
for a cluster (in our case, the Computer Science Division);
mail sent to a specific machine should ignore these defaults.
the name of the sending user is looked up in the database.
the value of that record is used as their outgoing name.
For example, I might have a record:
eric:mailname Eric.Allman@CS.Berkeley.EDU
This would cause my outgoing mail to be sent as Eric.Allman.
If present, this is the name of a host to override the local host.
For example, in our case we would set it to
The effect is that anyone known in the database
gets their outgoing mail stamped as
.q user@CS.Berkeley.EDU ,
but people not listed in the database use the local hostname.
.sh 1 "OTHER CONFIGURATION"
There are some configuration changes that can be made by
This section describes what changes can be made
and what has to be modified to make them.
.sh 2 "Parameters in src/Makefile"
These parameters are not intended to describe site policy;
these should be defined in src/conf.h.
in the UNIX Programmer's Manual).
a much less efficient algorithm for processing aliases is used.
the new version of the DBM library
that allows multiple databases will be used.
If set, use the new database package from Berkeley (from 4.4BSD).
This package is substantially faster than DBM or NDBM.
If NEWDB and DBM are both set,
sendmail will read old DBM files,
but will create and use NEWDB files.
this should never be used unless absolutely necessary.
Set all of the compilation parameters appropriate for System V.
Details are described below.
The are four built-in ways of computing the load average.
tries to auto-configure them based on imperfect guesses;
you can select one using the
The kernel stores the load average in the kernel as an array of long integers.
The actual values are scaled by a factor FSCALE
The kernel stores the load average in the kernel as an array of
routine to get the load average as an array of doubles.
Always return zero as the load average.
This is the fallback case.
you may also need to specify
(the path to your system binary)
(the name of the variable containing the load average in the kernel;
.sh 2 "Parameters in src/conf.h"
Parameters and compilation options
Most of these need not normally be tweaked;
common parameters are all in sendmail.cf.
However, the sizes of certain primitive vectors, etc.,
are included in this file.
The numbers following the parameters
The maximum line length of any input line.
If message lines exceed this length
they will still be processed correctly;
configuration file lines,
must fit within this limit.
The maximum length of any name,
such as a host or a user name.
The maximum number of parameters to any mailer.
This limits the number of recipients that may be passed in one transaction.
It can be set to any arbitrary number above about 10,
will break up a delivery into smaller batches as needed.
A higher number may reduce load on your system, however.
The maximum number of atoms
.q "eric@CS.Berkeley.EDU"
The maximum number of mailers that may be defined
in the configuration file.
The maximum number of rewriting sets
The maximum number of values for the
field that may be defined
The maximum number of trusted users that may be defined
.ip "MAXUSERENVIRON [40]"
The maximum number of items in the user environment
that will be passed to subordinate mailers.
The maximum number of entries that will be processed
The maximum number of MX records we will accept for any single host.
A number of other compilation options exist.
These specify whether or not specific code should be compiled in.
If set, debugging information is compiled in.
To actually get the debugging output,
.b "WE STRONGLY RECOMMEND THAT THIS BE LEFT ON."
Some people, believing that it was a security hole
have turned it off and thus crippled debuggers.
code to run a daemon is compiled in.
This code is for 4.2 or 4.3BSD.
routine in use at some sites is used.
This makes an informational log record
for each message processed,
and makes a higher priority log record
for internal system errors.
Compile in the code to do ``fuzzy matching'' on the GECOS field
This also requires that option G be turned on.
Compile in code to use the
Berkeley Internet Name Domain (BIND) server
to resolve TCP/IP host names.
If you are using a non-UNIX mail format,
you can set this flag to turn off special processing
This flag should be set to compile in the queueing code.
mailers must accept the mail immediately
or it will be returned to the sender.
array to indicate its current status.
This can be used in conjunction with the
command to find out just what it's up to.
the code to handle user and server SMTP will be compiled in.
This is only necessary if your machine has some mailer
(this means most machines everywhere).
If you have a UUCP host adjacent to you which is not running
you will have to set this flag to include the
Otherwise, UUCP gets confused about where the mail came from.
Berkeley user information database package.
This adds a new level of local name expansion
between aliasing and forwarding.
It also uses the NEWDB package.
This may change in future releases.
.sh 2 "Configuration in src/conf.c"
The following changes can be made in conf.c.
.sh 3 "Built-in Header Semantics"
Not all header semantics are defined in the configuration file.
Header lines that should only be included by certain mailers
(as well as other more obscure semantics)
This table contains the header name
(which should be in all lower case)
and a set of header control flags (described below),
Normally when the check is made to see if a header line is compatible
will not delete an existing line.
even existing header lines.
if this bit is set and the mailer does not have flag bits set
that intersect with the required mailer flags
in the header definition in
If this header field is set,
treat it like a blank line,
it will signal the end of the header
and the beginning of the message text.
even if one existed in the message before.
If a header entry does not have this bit set,
will not add another header line if a header line
of this name already existed.
This would normally be used to stamp the message
by everyone who handled it.
If the number of trace fields in a message
on the assumption that it has an aliasing loop.
this field contains recipient addresses.
flag to determine who to send to
when it is collecting recipients from the message.
This flag indicates that this field
The order of these fields in the
for which field to return error messages to.
.ta 4n +\w'"return-receipt-to", 'u
struct hdrinfo HdrInfo[] =
/* originator fields, most to least significant */
/* message identification and control */
"received", H_TRACE|H_FORCE,
This structure indicates that the
all specify recipient addresses.
field will be deleted unless the required mailer flag
(indicated in the configuration file)
fields will terminate the header;
these are used by random dissenters around the network world.
field will always be added,
and can be used to trace messages.
There are a number of important points here.
header fields are not added automatically just because they are in the
they must be specified in the configuration file
in order to be added to the message.
Any header fields mentioned in the configuration file but not
structure have default processing performed;
they are added unless they were in the message already.
structure only specifies cliched processing;
certain headers are processed specially by ad hoc code
regardless of the status specified in
fields are always scanned on ARPANET mail
this is used to perform the
fields are used to determine the full name of the sender
this is stored in the macro
and used in a number of ways.
also contains the specification of ARPANET reply codes.
There are four classifications these fall into:
.ta \w'char 'u +\w'Arpa_TUsrerr[] = 'u +\w'"888"; 'u
char Arpa_Info[] = "050"; /* arbitrary info */
char Arpa_TSyserr[] = "455"; /* some (transient) system error */
char Arpa_PSyserr[] = "554"; /* some (permanent) system error */
char Arpa_Usrerr[] = "554"; /* some (fatal) user error */
is for any information that is not required by the protocol,
such as forwarding information.
is printed out for transient errors,
errors that are likely to go away without explicit action
on the part of a systems administrator.
is printed for permanent errors.
The distinction is made based on the value of
is the result of a user error
these are generated when the user has specified something wrong,
and hence the error is permanent,
it will not work simply by resubmitting the request.
.sh 3 "Restricting Use of Email"
If it is necessary to restrict mail through a relay,
This routine is called for every recipient address.
to indicate that the address is acceptable
and mail processing will continue,
to print an error message
saying why the message is rejected.
.ta 4n +4n +4n +4n +4n +4n +4n
if (MsgSize > 50000 && to->q_mailer != LocalMailer)
usrerr("Message too large for non-local delivery");
This would reject messages greater than 50000 bytes
flag can be sent to suppress the return of the actual body
of the message in the error return.
The actual use of this routine is highly dependent on the
and use should be limited.
.sh 3 "Load Average Computation"
should return an approximation of the current system load average
There are four versions included on compilation flags
.sh 3 "New Database Map Classes"
New key maps can be added by creating a class initialization function
These are then added to the routine
The initialization function is called as
\fIxxx\fP_map_init(MAP *map, char *mapname, char *args)
is an internal data structure.
is the name of the map (used for error messages).
is a pointer to the rest of the configuration file line;
flags and filenames can be extracted from this line.
The initialization function must return
if it successfully opened the map,
The lookup function is called as
\fIxxx\fP_map_lookup(MAP *map, char buf[], int bufsize, char **av)
defines the map internally.
This may be (and often is) used destructively.
is a list of arguments passed in from the rewrite line.
The lookup function should return a pointer to the new value.
.sh 3 "Queueing Function"
is called to decide if a message should be queued
or processed immediately.
Typically this compares the message priority to the current load average.
The default definition is:
return (pri > (QueueFactor / (CurrentLA \- QueueLA + 1)));
If the current load average
which is set before this function is called)
is less than the threshold load average
Otherwise, it computes the function based on the message priority,
and the current and threshold load averages.
An implementation wishing to take the actual age of the message into account
which is the time that the message was first submitted to
parameter is already weighted
by the number of times the message has been tried
(although this tends to lower the priority of the message with time);
the expectation is that the
to ensure that messages are eventually processed.
.sh 3 "Refusing Incoming SMTP Connections"
if incoming SMTP connections should be refused.
The current implementation is based exclusively on the current load average
and the refuse load average option
return (CurrentLA > RefuseLA);
A more clever implementation
could look at more system resources.
.sh 3 "Load Average Computation"
returns the current load average (as a rounded integer).
The distribution includes several possible implementations.
.sh 2 "Configuration in src/daemon.c"
contains a number of routines that are dependent
on the local networking environment.
The version supplied is specific to 4.3 BSD.
we recommended that you modify the routine
if you wanted to generalize
We now recommend that you create a new keyed map instead.
.sh 1 "CHANGES IN RELEASE 6"
The following summarizes changes
since the last commonly available version of
.sh 2 "Connection Caching"
Instead of closing SMTP connections immediately,
those connections are cached for possible future use.
The advent of MX records made this effective for mailing lists;
substantial performance improvements can be expected for queue processing.
used the 0200 bit for quoting.
This version avoids that use.
However, for compatibility with RFC 822,
the default is still to strip the eighth bit;
set option `8' to get full 8-bit clean processing.
Individual mailers can still produce seven bit out put using the
The user database is an as-yet experimental attempt
to provide unified large-site name support.
We are installing it at Berkeley;
future versions may show significant modifications.
.sh 2 "Improved BIND Support"
particularly for MX records,
which have been removed in this release.
these more tightly bind (pun intended) the name server to sendmail,
so that the name server resolution rules are incorporated directly into
Generalized keyed files is an idea taken directly from
(albeit with a completely different implementation).
They can be useful on large sites.
.sh 2 "Parsing Bug Fixes"
A number of small bugs having to do with things like
backslash-escaped quotes inside of comments
.sh 2 "Separate From/Return-Path Processing"
Since the From: line is passed in separately from the envelope sender,
these have both been made visible;
macro gives access to the envelope sender information.
.sh 2 "Dynamic Header Allocation"
The fixed size limit on header lines has been eliminated.
.sh 2 "New Command Line Flag"
The \-p flag has been added
to pass in protocol information.
Several new options have been added,
many to support new features,
others to allow tuning that was previously available
They are described in detail in Section 5.1.5.
Connection cache lifetime.
Domain has no wildcard MX.
Release 6 allows up to 100 rulesets instead of 30.
It is recommended that rulesets 0\-9 be reserved for
dedicated use in future releases.
The total number of MX records that can be used has been raised to 20.
The number of queued messages that can be handled at one time
has been raised from 600 to 1000.
.sh 2 "Auto-Quoting in Addresses"
.q "Full Name <email address>"
syntax would generate incorrect protocol output
had special characters such as dot.
This version puts quotes around such names.
.sh 2 "Symbolic Names On Error Mailer"
Several names have been built in to the $@ portion of the $#error
.sh 2 "Portability and Security Enhancements"
A number of internal changes have been made to enhance portability.
Several fixes have been made to increase the paranoia factor.
Arguments must be presented with flags before addresses.
s Speak SMTP on input side
v Just verify addresses, don't collect or deliver
i Initialize the alias database
z Freeze the configuration file
Use a different configuration file.
runs as the invoking user (rather than root)
when this flag is specified.
The sender's machine address is
This flag is ignored unless the real user
contains an exclamation point
(because of certain restrictions in UUCP).
Sets the full name of this user to
This represents the number of times this message has been processed
(to the extent that it is supported by the underlying networks).
is incremented during processing,
throws away the message with an error.
Don't do aliasing or forwarding.
These options are described in Appendix B.
Set the sending protocol.
Programs are encouraged to set this.
The protocol field can be in the form
to set both the sending protocol and sending host.
sets the sending protocol to UUCP
and the sending host to uunet.
(Some existing programs use \-oM to set the r and s macros;
this is equivalent to using \-p.)
Try to process the queued up mail.
a sendmail will run through the queue at the specified interval
otherwise, it only runs once.
lines, and send to everyone listed in those lists.
line will be deleted before sending.
Any addresses in the argument vector will be deleted
There are a number of options that may be specified as
(provided for compatibility with
These are the e, i, m, and v options.
This appendix describes the format of the queue files.
These files live in the directory defined by the
All queue files have the name
\fIx\fP\|\fBf\fP\fIAA99999\fP
All files with the same id collectively define one message.
The message body (excluding the header) is kept in this file.
the job is currently being processed,
and a queue run will not process the file.
file can cause a job to apparently disappear
(it will not even time out!).
[Actually, this file is obsolete on most systems that support the
This file is created when an id is being created.
It is a separate file to insure that no mail can ever be destroyed
It should exist for no more than a few milliseconds
[This is only used on old versions of
This file contains the information necessary to process the job.
These are an image of the
file when it is being rebuilt.
It should be renamed to a
existing during the life of a session
showing everything that happens
file is structured as a series of lines
each beginning with a code letter.
The lines are as follows:
The name of the data file.
There may only be one of these lines.
There may be any number of these lines.
they represent the order in the final message.
These use the same syntax
as header definitions in the configuration file.
Recipient addresses following this line
will be flagged as having resulted from an alias of this name.
This affect the actual UNIX user id used for delivery.
This will normally be completely aliased,
but is actually realiased when the job is processed.
There may only be one of these lines.
they represent the addresses that should receive error messages.
This is used to compute when to time out the job.
The current message priority.
This is used to order the queue.
Higher numbers mean lower priorities.
as the message sits in the queue.
The initial priority depends on the message class
and the size of the message.
This line is printed by the
and is generally used to store status information.
The values of certain macros
(as of this writing, only
are passed through to the queue run phase.
the following is a queue file sent to
.q eric@mammoth.Berkeley.EDU
.q bostic@okeeffe.CS.Berkeley.EDU \**:
\**This example is contrived and probably inaccurate for your environment.
Glance over it to get an idea;
nothing can replace looking at what your own system generates.
Eowner-sendmail@vangogh.CS.Berkeley.EDU
Reric@mammoth.Berkeley.EDU
Rbostic@okeeffe.CS.Berkeley.EDU
H?P?return-path: <owner-sendmail@vangogh.CS.Berkeley.EDU>
Hreceived: by vangogh.CS.Berkeley.EDU (5.108/2.7) id AA06703;
Fri, 17 Jul 92 00:28:55 -0700
Hreceived: from mail.CS.Berkeley.EDU by vangogh.CS.Berkeley.EDU (5.108/2.7)
id AA06698; Fri, 17 Jul 92 00:28:54 -0700
Hreceived: from [128.32.31.21] by mail.CS.Berkeley.EDU (5.96/2.5)
id AA22777; Fri, 17 Jul 92 03:29:14 -0400
Hreceived: by foo.bar.baz.de (5.57/Ultrix3.0-C)
id AA22757; Fri, 17 Jul 92 09:31:25 GMT
H?F?from: eric@foo.bar.baz.de (Eric Allman)
H?x?full-name: Eric Allman
Hmessage-id: <9207170931.AA22757@foo.bar.baz.de>
HTo: sendmail@vangogh.CS.Berkeley.EDU
Hsubject: this is an example message
This shows the name of the data file,
the person who sent the message,
(in seconds since January 1, 1970),
and the headers for the message.
.+c "SUMMARY OF SUPPORT FILES"
This is a summary of the support files
Many of these can be changed by editing the sendmail.cf file;
check there to find the actual pathnames.
.ip "/usr/\*(SD/sendmail"
A link to /usr/\*(SD/sendmail;
causes the alias database to be rebuilt.
Running this program is completely equivalent to giving
Prints a listing of the mail queue.
This program is equivalent to using the
represented as a memory image.
A statistics file; need not be present.
The textual version of the alias file.
.ip /etc/aliases.{pag,dir}
The directory in which the mail queue
and temporary files reside.
.ip /var/spool/mqueue/qf*
Control (queue) files for messages.
.ip /var/spool/mqueue/df*
.ip /var/spool/mqueue/tf*
Temporary versions of the qf files,
used during queue file rebuild.
.ip /var/spool/mqueue/xf*
A transcript of the current session.
.\"INSTALLATION AND OPERATION GUIDE
.\" remove some things to avoid "out of temp file space" problem