Next | Prev | Up | Top | Contents | Index

The Mail Queue

This section discusses how to print and force the mail queue.


Listing the Queue

You can list the contents of the queue by using the mailq command or by specifying the -bp flag to sendmail. The list includes a listing of the queue IDs, the size of each message, the date the message entered the queue, and the sender and recipients.


Forcing the Queue

The -q flag (with no value) forces sendmail to process the queue. It is sometimes useful to use the -v flag (verbose) also when running the queue manually, as follows:

/usr/lib/sendmail -q -v

In verbose mode, sendmail displays the SMTP chatter with other stations as well as messages indicating any delivery errors and final message disposition.

Because of the locking algorithm, it is impossible for one job to freeze the queue. However, an uncooperative recipient station or a program recipient that never returns can consume many station resources. Unfortunately, there is no way to resolve this situation without violating the SMTP protocol used by sendmail.

In some cases, if a major station goes down for a couple of days, a prohibitively large queue may be created. As a result, sendmail spends an inordinate amount of time sorting the queue. You can remedy this situation by moving the queue to a temporary location and creating a new queue. The old queue can be run later when the offending station returns to service.

Use the following commands to move the entire queue directory. The mail queue should be owned by root and belong to the mail group.

cd /var/spool

mv mqueue omqueue

mkdir mqueue

chmod 755 mqueue

Then kill the existing sendmail daemon (because it will still be processing in the old queue directory) and create a new daemon:

/etc/init.d/mail stop

/etc/init.d/mail start

To run the old mail queue, use the following command:

/usr/lib/sendmail -oQ/var/spool/omqueue -q

The -oQ flag specifies an alternate queue directory, and the -q flag causes sendmail to run every job in the queue once and then return. Use the -v (verbose) flag to watch what is going on. It may be necessary to run the old mail queue a number of times before all of the messages can be delivered.

When the queue is finally emptied, the directory can be removed:

rmdir /var/spool/omqueue


Next | Prev | Up | Top | Contents | Index