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 parse addresses, 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 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. If you are running on a 4.4BSD system, compile by typing make. On other systems, you may have to make some other adjustments. On most systems, you can do the appropriate compilation by typing

sh makesendmail
This will leave the binary in an appropriately named subdirectory. It works for multiple object versions compiled out of the same directory.

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 new database package from Berkeley. 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 one of the other two; if you do, old 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 makesendmail is the best approach on most systems:

sh makesendmail
This will use uname(1) to select the correct Makefile for your environment.

You may be able to install using

sh makesendmail 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 or as a general description of a UUCP-connected host). 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/ is our description for hosts in the CS.Berkeley.EDU subdomain that want their individual hostname to be externally visible; domain/cs.hidden.m4 is the same except that the hostname is hidden (everything looks like it comes from CS.Berkeley.EDU). 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. They normally contain lists of site information, for example:
They are referenced using the SITECONFIG macro:
SITECONFIG(site.config.file, name_of_site, X)
where X is the macro/class name to use. It can be U (indicating locally connected hosts) or one of W, X, or Y for up to three remote UUCP hubs. 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: for example, Berkeley's domain definition defines relays for BitNET, CSNET, and UUCP. Of these, only the UUCP relay is particularly specific to Berkeley. 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 cf/domain directory. For example, the domain cs-exposed is the Computer Science subdomain with the local hostname shown to other users; cs-hidden 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 .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[1]. It should be setuid root. For security reasons, /, /usr, and /usr/sbin should be owned by root, mode 755[2].


This is the configuration file for sendmail [3]. This and /etc/ are the only non-library file names compiled into sendmail [4].

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. 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 version of these files maintained by the dbm(3) or db(3) routines. These are stored either in /etc/aliases.dir and /etc/aliases.pag or /etc/aliases.db 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
chmod 644 /etc/aliases.*
The db routines preset the mode reasonably, so this step can be skipped. The actual path of this file is defined in the AliasFile option of the file.


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:

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 startup script.

# 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
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*
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 H 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 October 25, 1997.

Claus Aßmann Please send comments to: <>