sendmail

sendmailSearch this book
Previous: 22.9 PitfallsChapter 23Next: 23.2 Parts of a Queued Message
 

23. The Queue

Contents:
Overview of the Queue
Parts of a Queued Message
A Bogus qf File (V8 only): Qf
Printing the Queue
How the Queue Is Processed
Cause the Queue to Be Processed
Process Alternate Queues
Pitfalls
The qf File Internals

Mail messages may either be delivered immediately or be held for later delivery. Held messages are referred to as "queued." They are placed into a holding directory, usually called mqueue, from which they are delivered at a later time. There are many reasons a mail message may be queued:

23.1 Overview of the Queue

The sendmail queue is implemented by placing held messages into a directory. That directory and its name (usually mqueue) are specified in the configuration file by the QueueDirectory (Q) option (see Section 34.8.48, QueueDirectory (Q)):

OQ/var/spool/mqueue                         <- pre-V8.7 form
O QueueDirectory=/var/spool/mqueue          <- beginning with V8.7

If the QueueDirectory (Q) option is missing, the name defaults to mqueue. When the location is relative (as mqueue), it is relative to the location where sendmail is run. Since the sendmail daemon is typically started from an rc file at boot time, such relative locations are usually relative to the root (/) directory. [1]

[1] Of course, if sendmail is started somewhere else or by someone else, the queue directory will be a subdirectory under that other starting directory.

After sendmail has processed its configuration file, it does a chdir(2) into its queue directory and does all the rest of its work from there. This change into the queue directory has two side effects:

The queue directory should be set to have very narrow permissions. It must be owned by root. We (and CERT) recommend a mode of 0700. Prior to V8 sendmail, such narrow permissions would cause C-shell scripts run from a ~/.forward files to fail. V8 sendmail lets you specify alternative directories in which to run programs (see the D= delivery agent equate, Section 30.4.3, D=). This allows you to use mode 0700 queue directories without the associated problems.

As a further precaution, all the components of the path leading to the queue directory should be owned by root and be writable only by root. In the case of our example of /var/spool/mqueue, permissions should look like this:

drwxr-xr-x  root    /
drwxr-xr-x  root    /var/
drwxr-xr-x  root    /var/spool/
drwx---  root    /var/spool/mqueue/

For additional security, see the restrictmailq keyword for the PrivacyOptions (p) option (see Section 34.8.47, PrivacyOptions (p)). It allows only users in the same group as the group ownership of the queue directory to be able to print its contents with mailq or -bp (see Section 23.4, "Printing the Queue").


Previous: 22.9 PitfallssendmailNext: 23.2 Parts of a Queued Message
22.9 PitfallsBook Index23.2 Parts of a Queued Message