System Administration Guide, Volume 3

Administering the Mail Queue

This section describes how to keep the mail service running smoothly.

How to Display the Mail Queue

You can print the contents of the queue with mailq.This command is equivalent to specifying the -bp flag to sendmail.

    Type /usr/bin/mailq | more and press Return.

A list of the queue IDs, the size of the message, the date the message entered the queue, the message status, and the sender and recipients are displayed.

How to Force Mail Queue Processing

    Type /usr/lib/sendmail -q -v and press Return.

This forces the processing of the queue and displays progress of the jobs as the queue is cleared.

How to Run a Subset of the Mail Queue

    Type /usr/lib/sendmail -qRstring and press Return.

You can run a subset of the queue at any time with the -qRstring (run queue where any recipient name matches string) or with -qInnnnn (run just one message with queue ID nnnnn). The string can also match host names, so any substring of user@host.domain will match.

This example processes everything in the queue for recipient wnj.


# /usr/lib/sendmail -qRwnj

How to Move the Mail Queue

  1. Become root on the mail host.

  2. Type /etc/init.d/sendmail stop and press Return.

    This kills the old sendmail daemon to keep it from trying to process the old queue directory.

  3. Type cd /var/spool and press Return.

  4. Type mv mqueue omqueue; mkdir mqueue and press Return.

    This moves the directory, mqueue, and all its contents to the omqueue directory and then creates a new empty Rmqueue directory.

  5. Type chmod 755 mqueue; chown daemon.daemon mqueue and press Return.

    These commands set the permissions of the directory to read/write/execute by owner, and read/execute by group and others; these commands also set the owner and group to daemon.

  6. Type /etc/init.d/sendmail start and press Return.

    This starts a new sendmail daemon.

How to Run the Old Mail Queue

  1. Type /usr/lib/sendmail -oQ/var/spool/omqueue -q and press Return.

    The -oQ flag specifies an alternate queue directory and the -q flag says to run every job in the queue. Use the -v flag if you want to see the verbose output displayed on the screen.

  2. When the queue is finally emptied type rmdir /var/spool/omqueue and press Return.

    This removes the empty directory.