11.9 Process Alternate QueuesThe 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 SiteIf 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. 11.9.1.1 Move mail with qtool.plIf 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]
# 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. 11.9.1.2 Move mail with queue groupsTo 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:
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. |