There are two basic steps to installing sendmail. First, you have to compile and install the binary. If sendmail has already been ported to your operating system that should be simple. Second, you must build a run-time configuration file. This is a file that sendmail reads when it starts up that describes the mailers it knows about, how to parse addresses, how to rewrite the message header, and the settings of various options. Although the configuration file can be quite complex, a configuration can usually be built using an M4-based configuration language.

The remainder of this section will describe the installation of sendmail assuming you can use one of the existing configurations and that the standard installation parameters are acceptable. All pathnames and examples are given from the root of the sendmail subtree, normally /usr/src/usr.sbin/sendmail on 4.4BSD.

If you are loading this off the tape, continue with the next section. If you have a running binary already on your system, you should probably skip to section 1.2.

Compiling Sendmail

All sendmail source is in the src subdirectory. To compile sendmail, cd into the src directory and type

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.

Tweaking the Build Invocation

You can give parameters on the Build command. In most cases these are only used when the obj.* directory is first created. These commands include:

-L libdirs
A list of directories to search for libraries.
-I incdirs
A list of directories to search for include files.
-E envar=value
Set an environment variable to an indicated value before compiling. This is normally used to set an ABI on Irix.
Create a new obj.* tree before running.
-f siteconfig
Read the indicated site configuration file. If this parameter is not specified, Build includes all of the files $BUILDTOOLS/Site/site.$oscf.m4 and $BUILDTOOLS/Site/site.config.m4, where $BUILDTOOLS is normally ../BuildTools and $oscf is the same name as used on the obj.* directory. See below for a description of the site configuration file.
Skip auto-configuration. Build will avoid auto-detecting libraries if this is set. All libraries and map definitions must be specified in the site configuration file.

Any other parameters are passed to the make program.

Creating a Site Configuration File

(This section is not yet complete. For now, see the file BuildTools/README for details.)

Tweaking the Makefile

Sendmail supports two different formats for the local (on disk) version of databases, notably the aliases database. At least one of these should be defined if at all possible.

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.
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 define 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 defined, and if the alias file name includes the substring /yp/, sendmail will create both new and old versions of the alias file during a newalias command. This is required because the Sun NIS/YP system reads the DBM version of the alias file. It's ugly as sin, but it works.

If neither of these are defined, sendmail reads the alias file into memory on every invocation. This can be slow and should be avoided. There are also several methods for remote database access:

Sun's Network Information Services (formerly YP).
Sun's NIS+ services.
NeXT's NetInfo service.
Hesiod service (from Athena).

Other compilation flags are set in conf.h and should be predefined for you unless you are porting to a new environment.

Compilation and installation

After making the local system configuration described above, You should be able to compile and install the system. The script Build is the best approach on most systems:

This will use uname(1) to create a custom Makefile 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 4.4BSD systems it will also format and install man pages.

Configuration Files

Sendmail cannot operate without a configuration file. The configuration defines the mail delivery mechanisms understood at this site, how to access them, 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.

The sendmail configuration can be daunting at first. The world is complex, 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; in particular, text-based host files are officially eliminated, obviating the need to hide hosts behind a registered internet gateway.

These files also assume that most of your neighbors use domain-based UUCP addressing; that is, instead of naming hosts as host!user they will use host.domain!user. The configuration files can be customized to work around this, but it is more complex.

Our configuration files are processed by m4 to facilitate local customization; the directory cf of the sendmail distribution directory contains the source files. This directory contains several subdirectories:

Both site-dependent and site-independent descriptions of hosts. These can be literal host names (e.g., when the hosts are gateways or more general descriptions (such as as a general description of an SMTP-connected host running Solaris 2.x. Files ending .mc (``Master Configuration'') are the input descriptions; the output is in the corresponding .cf file. The general structure of these files is described below.
Site-dependent subdomain descriptions. These are tied to the way your organization wants to do addressing. For example, domain/CS.Berkeley.EDU.m4 is our description for hosts in the CS.Berkeley.EDU subdomain. These are referenced using the DOMAIN m4 macro in the .mc file.
Definitions of specific features that some particular host in your site might want. These are referenced using the FEATURE m4 macro. An example feature is use_cw_file (which tells sendmail to read an /etc/ file on startup to find the set of local names).
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.
Site-independent m4(1) include files that have information common to all configuration files. This can be thought of as a #include directory.
Definitions of mailers, referenced using the MAILER m4 macro. The mailer types that are known in this distribution are fax, local, smtp, uucp, and usenet. For example, to include support for the UUCP-based mailers, use MAILER(uucp).
Definitions describing various operating system environments (such as the location of support files). These are referenced using the OSTYPE m4 macro.
Shell files used by the m4 build process. You shouldn't have to mess with these.
Local UUCP connectivity information. This directory has been supplanted by the mailertable feature; any new configurations should use that feature to do UUCP (and other) routing.

If you are in a new domain (e.g., a company), you will probably want to create a cf/domain file for your domain. This consists primarily of relay definitions and features you want enabled site-wide: for example, Berkeley's domain definition defines relays for BitNET and UUCP. These are specific to Berkeley, and should be fully-qualified internet-style domain names. Please check to make certain they are reasonable for your domain.

Subdomains at Berkeley are also represented in the cf/domain directory. For example, the domain CS.Berkeley.EDU is the Computer Science subdomain, EECS.Berkeley.EDU is the Electrical Engineering and Computer Sciences subdomain, and S2K.Berkeley.EDU is the Sequoia 2000 subdomain. You will probably have to add an entry to this directory to be appropriate for your domain.

You will have to use or create .mc files in the cf/cf subdirectory for your hosts. This is detailed in the cf/README file.

Details of Installation Files

This subsection describes the files that comprise the sendmail installation.


The binary for sendmail is located in /usr/sbin[2]. It should be setuid root. For security reasons, /, /usr, and /usr/sbin should be owned by root, mode 755[3].


This is the configuration file for sendmail [4]. This is the only non-library file name compiled into sendmail [5].

The configuration file is normally created using the distribution files described above. If you have a particularly unusual system configuration you may need to create a special version. The format of this file is detailed in later sections of this document.


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.


The hoststat command should just be a link to sendmail, in a fashion similar to newaliases. This command lists the status of the last mail transaction with all remote hosts. The -v flag will prevent the status display from being truncated. It functions only when the HostStatusDirectory option is set.


This command is also a link to sendmail. It flushes all information that is stored in the HostStatusDirectory tree.


The directory /var/spool/mqueue should be created to hold the mail queue. This directory should be mode 700 and owned by root.

The actual path of this directory is defined in the Q option of the file.


This is a typical value for the HostStatusDirectory option, containing one file per host that this sendmail has chatted with recently. It is normally a subdirectory of mqueue.


The system aliases are held in /etc/aliases. A sample is given in lib/aliases which includes some aliases which must be defined:

cp lib/aliases /etc/aliases
edit /etc/aliases
You should extend this file with any aliases that are apropos to your system.

Normally sendmail looks at a database version of the files, stored either in /etc/aliases.dir and /etc/aliases.pag or /etc/aliases.db depending on which database package you are using. The actual path of this file is defined in the AliasFile option of the file.

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

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 /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 files, typically /etc/init.d/sendmail:

if [ -f /usr/sbin/sendmail -a -f /etc/ ]; then
(cd /var/spool/mqueue; rm -f [lnx]f*)
/usr/sbin/sendmail -bd -q30m &
echo -n ' sendmail' >/dev/console
The cd and rm 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 sendmail has two flags: -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 files and df files for which there is no qf file. For example, see Figure 1 for an example of a complex script which does this clean up.

# remove zero length qf files
for qffile in qf*
if [ -r $qffile ]
if [ ! -s $qffile ]
echo -n " <zero: $qffile>" > /dev/console
rm -f $qffile
# rename tf files to be qf if the qf does not exist
for tffile in tf*
qffile=`echo $tffile | sed 's/t/q/'`
if [ -r $tffile -a ! -f $qffile ]
echo -n " <recovering: $tffile>" > /dev/console
mv $tffile $qffile
if [ -f $tffile ]
echo -n " <extra: $tffile>" > /dev/console
rm -f $tffile
# remove df files with no corresponding qf files
for dffile in df*
qffile=`echo $dffile | sed 's/d/q/'`
if [ -r $dffile -a ! -f $qffile ]
echo -n " <incomplete: $dffile>" > /dev/console
mv $dffile `echo $dffile | sed 's/d/D/'`
# announce files that have been saved during disaster recovery
for xffile in [A-Z]f*
if [ -f $xffile ]
echo -n " <panic: $xffile>" > /dev/console

Figure 1 -- A complex startup script

If you are not running a version of UNIX that supports Berkeley TCP/IP, do not include the -bd flag.


This is the help file used by the SMTP HELP command. It should be copied from lib/sendmail.hf:

cp lib/sendmail.hf /usr/lib
The actual path of this file is defined in the HelpFile option of the file.


If you wish to collect statistics about your mail traffic, you should create the file /etc/

cp /dev/null /etc/
chmod 666 /etc/
This file does not grow. It is printed with the program mailstats/mailstats.c. The actual path of this file is defined in the S option of the file.


If sendmail is invoked as mailq, it will simulate the -bp flag (i.e., sendmail will print the contents of the mail queue; see below). This should be a link to /usr/sbin/sendmail.

[Contents] [Previous] [Next]
This document was translated by troff2html v0.21 on January 4, 1999.

Claus Aßmann Please send comments to: <>