Mail is queued in the /var/spool/mqueue directory
before being transmitted. This directory is called the mail spool.
The sendmail program provides a means of displaying a
formatted list of all spooled mail messages and their status.

The /usr/bin/mailq command is a symbolic link to the
sendmail executable and behaves indentically to:

# sendmail -bp

The output displays the message ID, its size, the time it was placed in the
queue, who sent it, and a message indicating its current status. The following
example shows a mail message stuck in the queue with a problem:

If you use a temporary dial-up Internet connection with a
fixed IP address and rely on an MX host to collect your
mail while you are disconnected, you will find it useful to force the MX host
to process its mail queue soon after you establish your connection.

A small perl program is included with the
sendmail distribution that makes this simple for mail
hosts that support it. The etrn script has much the same
effect on a remote host as the runq command has on our
own. If we invoke the command as shown in this example:

# etrn vstout.vbrew.com

we will force the host vstout.vbrew.com to process any mail queued for our local machine.

Typically you'd add this command to your PPP ip-up script
so that it is executed soon after your network connection is established.

The mailstats command displays statistics on the
volume of mail processed by sendmail. The time at
which data collection commenced is printed first, followed by a table
with one row for each configured mailer and one showing a summary
total of all mail. Each line presents eight items of information:

Field

Meaning

M

The mailer (transport protocol) number

msgsfr

The number of messages received from the mailer

bytes_from

The Kbytes of mail from the mailer

msgsto

The number of messages sent to the mailer

bytes_to

The Kbytes of mail sent to the mailer

msgsreg

The number of messages rejected

msgsdis

The number of messages discarded

Mailer

The name of the mailer

A sample of the output of the mailstats command is shown
in Example 18-5.

The hoststat command displays information about the
status of hosts that
sendmail has attempted to deliver mail to. The
hoststat command is equivalent to invoking
sendmail as:

sendmail -bh

The output presents each host on a line of its own, and for each the
time since delivery was attempted to it, and the status message
received at that time.

Example 18-6 shows the sort of output you can
expect from the hoststat command. Note that most of the
results indicate successful delivery. The result for
earthlink.net, on the other hand, indicates
that delivery was unsuccessful. The status message can sometimes help
determine the cause of the failure. In this case, the connection timed out,
probably because the host was down or unreachable at the time delivery was
attempted.

The purgestat command flushes the collected host data and
is equivalent to invoking sendmail as:

# sendmail -bH

The statistics will continue to grow until you purge them. You might
want to periodically run the purgestat command to make it
easier to search and find recent entries, especially if you have a busy site.
You could put the command into a crontab file so it
runs automatically, or just do it yourself occasionally.