3. The Roles of sendmail
Contents:
The sendmail program plays a variety of roles, all critical to the proper flow of electronic mail. It listens to the network for incoming mail, transports mail messages to other machines, and hands local mail to a local program for local delivery. It can append mail to files and can pipe mail through other programs. It can queue mail for later delivery and understands the aliasing of one recipient name to another. 3.1 Role in the FilesystemThe sendmail program's role (position) in the local file system hierarchy can be viewed as an inverted tree (see Figure 3.1 ). Figure 3.1: The sendmail.cf file leads to everything elseWhen sendmail is run, it first reads the /etc/sendmail.cf configuration file. Among the many items contained in that file are the locations of all the other files and directories that sendmail needs. Files and directories listed in sendmail.cf are usually specified as full pathnames for security (such as /var/spool/mqueue rather than mqueue ). As the first step in our tour of those files, run the following command to gather a list of them: [1]
% The output produced by the grep (1) command may look something like the following: [2]
O AliasFile=/etc/aliases #O ErrorHeader=/etc/sendmail.oE O HelpFile=/usr/lib/sendmail.hf O QueueDirectory=/var/spool/mqueue O StatusFile=/etc/sendmail.st #O UserDatabaseSpec=/etc/userdb #O ServiceSwitchFile=/etc/service.switch #O HostsFile=/etc/hosts #O SafeFileEnvironment=/arch Mlocal, P=/bin/mail, F=lsDFMAw5:/|@rmn, S=10/30, R=20/40, Mprog, P=/bin/sh, F=lsDFMoeu, S=10/30, R=20/40, D=$z:/,
Notice that some lines begin with an
First we will examine the files in the 3.1.1 The Aliases FileAliasing is the process of converting one recipient name into another. One use is to convert a generic name (such as root ) into a real username. Another is to convert one name into a list of many names (for mailing lists).
Take a few moments to examine your
aliases
file. Its
location is determined by the
O AliasFile=/etc/aliases Compare what you find in your aliases file to the brief example of an aliases file listed below:
Your aliases file is probably far more complex, but even so, note that the example shows all the possible forms of aliases.
Lines that begin with
For every envelope that lists a local user as a recipient,
sendmail
looks up that recipient's name in the
aliases
file. (A local user is any address that would normally be delivered
on the local machine.
That is,
postmaster
is local, whereas
postmaster@remote
may not be.)
When
sendmail
matches the recipient to one of the
names on the left of the
aliases
file, it replaces that
recipient name with the text to the right of the
After a name is substituted, the new name is then looked up,
and the process is repeated until
no more matches are found.
The name
Every
aliases
file must have an alias for
When mail is
bounced (returned because it could not be delivered),
it is always sent from The five types of lines in an aliases file areas are as follows:
You have already seen the first (it was the form used to convert
The
The
The
The The aliases file can become very complex. It can be used to solve many special mail problems. The aliases file is covered in greater detail in Chapter 24, Aliases . 3.1.2 The Queue DirectoryA mail message can be temporarily undeliverable for a wide variety of reasons, such as when a remote machine is down or has a temporary disk problem. To ensure that such messages are eventually delivered, sendmail stores them in its queue directory until they can be delivered successfully.
The
The location of that directory must be a full pathname. Its exact
location varies from vendor to vendor, but you
can always find it by looking for the If you have permission, take a look at the queue directory. It may be empty if there is no mail waiting to be sent. If it is not empty, it will contain files like these:
dfQAA07038 dfMAA08000 qfQAA07038 qfMAA08000
When a mail message is queued, it is split into two parts,
each part being saved in a separate file. The header information
is saved in a file whose name begins with the characters
The example above shows two queued mail messages. One
is identified by the unique string The internals of the queue files and the processing of those files are covered in Chapter 23, The Queue . |
|