The mail queue is a directory that stores data and controls files for mail messages that the sendmail command delivers. By default, the mail queue is /var/spool/mqueue.
Mail messages might be queued for many reasons.
For example:
The contents of the queue can be printed using the mailq command (or by specifying the -bp flag with the sendmail command).
These commands produce a listing of the queue IDs, the sizes of the messages, the dates the messages entered the queue, and the senders and recipients.
Each message in the queue has a number of files associated with it. The files are named according to the following conventions:
TypefID
where ID is a unique message queue ID, and Type is one of the following letters indicating the type of file:
For example, if a message has a queue ID of AA00269, the following files are created and deleted in the mail queue directory while the sendmail command tries to deliver the message:
dfAA00269 | Data file |
qfAA00269 | Control file |
tfAA00269 | Temporary file |
xfAA00269 | Transcript file |
The q control file contains a series of lines, each beginning with a code letter:
The q file for a message sent to amy@zeus would look similar to:
P217031 T566755281 MDeferred: Connection timed out during user open with zeus Sgeo Ramy@zeus H?P?return-path: <geo> Hreceived: by george (0.13 (NL support)/0.01) id AA00269; Thu, 17 Dec 87 10:01:21 CST H?D?date: Thu, 17 Dec 87 10:01:21 CST H?F?From: geo Hmessage-id: <8712171601.AA00269@george> HTo: amy@zeus Hsubject: test
Where:
To set the message time-out and queue processing interval, you must use a specific format for the time value. The format of a time value is:
-qNumberUnit
where Number is an integer value and Unit is the unit letter. Unit can have one of the following values:
s | Seconds |
m | Minutes |
h | Hours |
d | Days |
w | Weeks |
If Unit is not specified, the sendmail daemon uses minutes (m) as the default. Here are three examples illustrating time-value specification:
/usr/sbin/sendmail -q15d
This command tells the sendmail daemon to process the queue every 15 days.
/usr/sbin/sendmail -q15h
This command tells the sendmail daemon to process the queue every 15 hours.
/usr/sbin/sendmail -q15
This command tells the sendmail daemon to process the queue every 15 minutes.
In some cases, you might find that the queue is clogged for some reason. You can force a queue to run using the -q flag (with no value). You can also use the -v flag (verbose) to watch what happens:
/usr/sbin/sendmail -q -v
You can also limit the jobs to those with a particular queue identifier, sender, or recipient using one of the queue modifiers. For example, -qRsally restricts the queue run to jobs that have the string sally in one of the recipient addresses. Similarly, -qSstring limits the run to particular senders, and -qIstring limits it to particular queue identifiers.
The value of the -q flag when the daemon starts determines the interval at which the sendmail daemon processes the mail queue.
The sendmail daemon is usually started by the /etc/rc.tcpip file, at system startup. The /etc/rc.tcpip file contains a variable called the queue processing interval (QPI), which it uses to specify the value of the -q flag when it starts the sendmail daemon. By default, the value of qpi is 30 minutes. To specify a different queue processing interval:
qpi=30m
These changes will take effect at the next system restart. If you want the changes to take effect immediately, stop and restart the sendmail daemon, specifying the new -q flag value. See Stopping the sendmail Daemon and Starting the sendmail Daemon for more information.
When a host goes down for an extended period, many messages routed to (or through) that host might be stored in your mail queue. As a result, the sendmail command spends a long time sorting the queue, severely degrading your system performance. If you move the queue to a temporary place and create a new queue, the old queue can be run later when the host returns to service. To move the queue to a temporary place and create a new queue:
cd /var/spool mv mqueue omqueue
/usr/sbin/sendmail -oQ/var/spool/omqueue -q
The -oQ flag specifies an alternate queue directory. The -q flag specifies to run every job in the queue. To get a report about the progress of the operation, use the -v flag.
Note: This operation can take a long time.
rm /var/spool/omqueue/* rmdir /var/spool/omqueue
To start the sendmail daemon, enter either of the following commands:
startsrc -s sendmail -a "-bd -q15"
/usr/lib/sendmail -bd -q15
If the sendmail daemon is already active when you enter one of these commands, you see the following message on the screen:
The sendmail subsystem is already active. Multiple instances are not supported.
If the sendmail daemon is not already active, then you see a message indicating that the sendmail daemon has been started.
To stop the sendmail daemon, run the stopsrc -s sendmail command.
If the sendmail daemon was not started with the startsrc command: