11.9 Process Alternate Queues

The sendmail program provides the ability to use queue directories other than the one listed in the configuration file's QueueDirectory option (QueueDirectory). Other queue directories can be used to solve an assortment of problems. One example is a site being down for an extended period. When a lot of mail is sent to such a site, messages collect in the queue and eventually start timing out. By moving those messages to a separate queue directory and processing it at a later time (when that site is back up), unnecessary bouncing of mail can be prevented.

Note that the QueueDirectory option is not safe. If its value is changed by anyone other than root, sendmail runs as an ordinary user.

11.9.1 Handling a Down Site

If a site is down, messages to that site can collect in the queue. If the site is expected to be down for a protracted period of time, those queued messages will begin to time out and bounce. To prevent them from bouncing, you can move them to a separate queue directory. Later, when the down site comes back up, you can process that separate queue.

There are two ways to move mail to a holding queue. One way is to simply move them to a different directory, but you cannot do that if you are using queue groups. The other way is to use queue groups, as we show later. Move mail with qtool.pl

If you are not using queue groups, you can move the affected messages to a separate queue using the contrib/qtool.pl script supplied with the sendmail source. If you are using queue groups, you should skip to the next section.

To use qtool.pl, you first make a destination directory, if one does not already exist:

# mkdir /var/spool/newqueue
# chmod 700 /var/spool/newqueue

Next, run qtool.pl to move messages from the regular queue to the new holding queue:[12]

[12] We fudge on this command. It actually moves all mail from the current queue to the new queue directory. You might have to supply other arguments to qtool.pl to select specific qf files to move. See the manual page, called contrib/qtool.8, for more information.

# contrib/qtool.pl /var/spool/newqueue /var/spool/mqueues/q.1

When the down site comes back up at a later time (say, 50 days later), the messages that have been saved in the holding directory can be delivered by running the following command by hand (it has been wrapped to fit the page):

% /usr/sbin/sendmail -OQueueDirectory=/var/spool/newqueue -OTimeout.queuereturn=51d
-OTimeout.queuewarn=0 -q

The -OTimeout.queuereturn=51d causes the time-to-live in the queue to be extended to 51 days or one day longer than the oldest held message. This prevents the held mail from wrongly bouncing when you try to deliver it, should the site not really be up yet.

The -OTimeout.queuewarn=0 prevents nondelivery warnings from being sent that might confuse the sender. Move mail with queue groups

To move mail to a new queue with queue groups, the process is exactly the same as we have shown already, but with a few wrinkles. You have to stop sendmail, move the messages to a queue from which sendmail will not deliver, then restart sendmail. The key differences between this approach and the one described in the previous section are:

  • The sendmail program should not be running when you move the messages out of the queue with qtool.pl.

  • When the down site comes back up, stop sendmail again, and move the messages back to the queue from where they came with qtool.pl. Process them there by hand with a long Timeout.queuereturn. When all of the backlogged mail has flushed, you can restart sendmail to run as normal.

If it is not possible to stop sendmail for the time needed to flush the old messages, you can leave the messages in the holding queue. For this to work, you will need to generate a configuration file that does not use queue groups, and use that configuration file to flush the holding queue.

    Part I: Build and Install
    Part II: Administration
    Part III: The Configuration File