Installing and Running sendmail

Installing and Running sendmail

The full sendmail distribution consists of three RPM packages: sendmail, sendmail-cf, and sendmail-doc. Only the first package is truly necessary to send and receive mail on your machine. The second package includes configuration macros and other files that can help you reconfigure your site's sendmail installation if the defaults are insufficient. The third package contains documentation files that help to explain some of the details of the current version.

The sendmail binary packages are included in the Red Hat distribution. The sendmail package is on CD #1, while the sendmail-cf package is on CD #2, and the sendmail-doc package is on CD #3. From the Red Hat RPMS directory on each CD-ROM, the following command installs the packages:

# rpm -ivv sendmail*

Starting sendmail

Once installed, the sendmail service is turned on by default. To start sendmail immediately, you can either reboot the machine or just run /etc/init.d/sendmail start to start the server. The procedure for starting and stopping sendmail is no different from that of other server processes.

Incoming messages received by sendmail are processed and stored in the /var/spool/mail directory. Each file in this directory represents a valid user name on the local machine. The file is created automatically when you add a user. People with login accounts use this directory and their user account name as their incoming mailboxes (for example, /var/spool/mail/johnq).

Outgoing messages go in /var/spool/mqueue directory while waiting to be sent. Filenames in this directory follow a consistent naming scheme. The first two characters indicate what type of data is stored in the file (see Table 19-1). Subsequent characters form a unique random identifier based on the PID of the sendmail process that is handling that message.

Table 19-1: File Prefixes in /var/spool/mqueue

Filename Prefix

Type of Data Stored

df

The data that constitutes the body of an e-mail message.

qf

The queue control file that contains the message headers and other administrative details.

tf

A temporary copy of the qf file, created if delivery errors occur.

xf

Any error messages generated while trying to send the message.

Other programs

Several other executable programs are included in the distribution. These are described in Table 19-2.

Table 19-2: Other Related Sendmail Programs

Program

Description

mailq

Displays a summary of the messages awaiting processing in the mail queue (the command is equivalent to sendmail -bp).

mailstats

Displays message quantity and byte count statistics.

makemap

Translates text files (/etc/mail/virtusertable) to hashed Berkeley databases ( /etc/mail/virtusertable.db). This command runs each time the sendmail script starts at boot time.

newaliases

Translates the plain-text /etc/aliases file into the hashed Berkeley database file /etc/aliases.db (the command is equivalent to sendmail -bi).

praliases

Prints out all aliases defined in /etc/aliases.

procmail

Not included with the sendmail package, but is used as an MDA for sendmail. (It is included in Red Hat Linux in the procmail package.)

purgestat

Clears the directory where host status information is stored. The command is equal to sendmail -bH, which is disabled by default.

rmail

Handles incoming mail via UUCP.

smrsh

Implements a restricted shell for running programs from sendmail.

Logging performed by sendmail

The amount of logging performed by sendmail is configurable in the sendmail.cf file, but the default level provides good coverage of informational notices and error messages. By default, the syslog facility (/etc/syslog.conf file) stores logging information from sendmail in the /var/log/maillog file. A few examples from this file are shown in this section.

An informational message similar to the following is written in the /var/log/maillog file each time the daemon starts (which also causes the hashed alias database to be regenerated):

Feb 16 12:52:40 toys sendmail[1758]: alias database /etc/aliases
       rebuilt by root
Feb 16 12:52:40 toys sendmail[1758]: /etc/aliases: 63 aliases, longest
                          10 bytes, 625 bytes total
Feb 16 12:52:40 toys sendmail[1787]: starting daemon (8.12.8):
                              SMTP+queueing@01:00:00

Each time a message is sent or received, a log file entry is created:

Feb 16 12:54:34 toys sendmail[1120]: OAA01120: from=root, size=161,
  class=0, pri=3 0161, nrcpts=1,
  msgid=<199907191254.OAA01120@toys.linuxtoys.net>, relay=root@localhost
Feb 16 12:54:35 toys sendmail[1127]: OAA01120: to=jkpat, ctladdr=root
  (0/0), delay=00:00:01, xdelay=00:00:00, mailer=local, stat=Sent

The logs even show when people attempt things that perhaps they shouldn't try. The wiz and debug commands were implemented in earlier versions of sendmail and were found to be a huge security problem. You may log file entries, such as those shown in the code examples below, as people with malicious intent check to make sure that you're not running a vulnerable sendmail daemon. Also, the expn and vrfy commands (which can be disabled via a configuration option) could give out more information than you'd care to distribute.

Feb 16 13:03:27 toys sendmail[699]: NOQUEUE: "wiz" command from localhost
    [127.0.0 .1] (127.0.0.1)
Feb 16 13:03:29 toys sendmail[699]: NOQUEUE: "debug" command from
    localhost [127.0 .0.1] (127.0.0.1)
Feb 16 13:03:37 toys sendmail[701]: NOQUEUE: localhost [127.0.0.1]:
    expn oracle
Feb 16 13:03:43 toys sendmail[702]: NOQUEUE: localhost [127.0.0.1]:
    vrfy oracle



Part IV: Red Hat Linux Network and Server Setup