Chapter 7. sendmail

Table of Contents
7.1. sendmail Components
7.2. Redirecting Mail
7.3. Logging
7.4. sendmail Configuration

This chapter describes sendmail(8), a facility for routing mail across an internetwork. This chapter is for system administrators who set up and maintain the mail system on a system or network.

The sendmail command implements a general purpose internetwork mail routing facility under the UNICOS/mp operating system. It is not tied to any one transport protocol -- its function may be likened to a crossbar switch, relaying messages from one domain into another. In the process, it can do a limited amount of message header editing to put the message into a format that is appropriate for the receiving domain. All of this is done under the control of a configuration file. Due to the requirements of flexibility for sendmail, the configuration file can seem somewhat unapproachable. However, there are only a few basic configurations for most sites, for which standard configuration files have been supplied. Most other configurations can be built by adjusting an existing configuration file incrementally.

7.1. sendmail Components

Components of sendmail include daemons, scripts, files, and commands. This section describes the various sendmail components.

7.1.1. /usr/libexec/sendmail

The main daemon, /usr/libexec/sendmail, 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. sendmail is normally started at system boot time from the /etc/init.d/mail script. For a complete list of options, see the sendmail(1) man page.

The default command in the startup script is:

sendmail -bd -q15m

The -bd flag causes sendmail to run as a daemon and the -q flag specifies the mail queue processing interval, in this example every 15 minutes. See the sendmail(8) man page.

7.1.2. /etc/init.d/mail

The /etc/init.d/mail script can be used to start or stop the sendmail daemon. For example, to implement changes to the configuration file, you must stop all running sendmail processes, refreeze the configuration file, and restart the sendmail daemon before the new configuration file will take effect. This script takes a single argument, either start or stop, which starts or stops the sendmail daemon respectively. You must be superuser (root) to use this script.

7.1.3. /etc/mail/sendmail.cf

This is the main configuration file for sendmail. The /etc/mail/sendmail.cf file is an ASCII file that contains most of the configuration information and is read at run time. This file is designed to be generated from the m4 processor and should NOT be edited directly.

The preinstalled sendmail.cf file is configured for a generic system and may suit your needs. You may want to personalize this file, for instance, if you want to configure the sendmail daemon to relay all messages to a central mail server on your network. You should not edit sendmail.cf directly. See Section 7.4 for information regarding using the m4 macro processor to create a new sendmail.cf file.

7.1.4. /usr/share/sendmail/ostype/unicosmp.m4

The unicosmp.m4 file contains definitions for the sendmail environment under the UNICOS/mp operating system. It should not be modified. The .mv file used to generate sendmail.cf under UNICOS/mp includes these definitions with the line: OSTYPE(unicosmp)

7.1.5. /etc/mail/aliases*

The aliases file contains the text form of the alias database used by the sendmail program. The alias database contains aliases for local mail recipients. For example, the following alias delivers mail addressed to jd on the local system to johndoe@company.com: jd:johndoe@company.com

When sendmail starts up, it automatically processes the aliases file into the file /etc/mail/aliases.dir and /etc/mail/aliases.pag. The aliases.dir and aliases.pag are NDBM versions of the aliases database. The NDBM format improves sendmail performance.

Note: The newaliases program must be run after modifying the alias database file.

7.1.6. /usr/sbin/newaliases

The newaliases program is used to rebuild the NDBM version of the aliases database. This program must be run any time the text version of the aliases file is modified. If not, the changes are not incorporated into the NDBM alias database and are not seen by the sendmail program. To rebuild the NDBM version of the database without restarting sendmail, enter the newaliases command. Executing this command is equivalent to executing sendmail with the -bi flag:

% /usr/lib/sendmail -bi

7.1.7. /var/spool/mqueue

The mail queue, /var/spool/mqueue, is the directory where the mail queue and temporary files reside. The messages are stored in various queue files that exist under the /var/spool/mqueue directory. Queue files take these forms:

qf* 

Control (queue) files for messages

df* 

Data files

tf* 

Temporary files

nf* 

A file used when a unique ID is created

xf* 

Transcript file of the current session

Normally, a sendmail subdaemon processes the messages in this queue periodically, attempting to deliver each message. (The /etc/init.d/mail script starts the sendmail daemon so that it forks a subdaemon every 15 minutes to process the mail queue.) Each time sendmail processes the queue, it reads and sorts the queue, then attempts to run all jobs in order.

7.1.8. /var/mail

The /var/mail directory houses all incoming mail for each user on a local system. For example, the user guest receives mail in the file /var/mail/guest.