Introduction

The queue is where mail is held until it can be successfully delivered. The queue holds mail for later delivery when a temporary error is encountered during the delivery process. Most sendmail administrators have seen "Deferred" appear in an error message and know that it means the mail will be held in the queue until the next queue run. Mail is also placed in the queue when the system load exceeds the load average defined by the sendmail.cf QueueLA option, and when certain delivery modes are used. Queuing is an important component of creating a robust, reliable mail delivery system.

Each mail message in the queue can be represented by up to four queue files:

  • The df file contains the message body.

  • The qf file contains the message headers and the queue control information needed to deliver the message.

  • The xf file is a temporary file that contains a transcript of any error messages sendmail receives when attempting to deliver the message. Any error messages collected in the xf file are returned to the sender, and the xf file is deleted after the delivery attempt.

  • The tf file is a temporary work file that sendmail uses to produce the updated qf file. The queue control information in the qf file is updated each time a message is requeued. Any changes to that information take place in the tf file to safeguard the qf file. After the tf file is successfully updated, it is renamed as a qf file.

Of the four file types, only the df and qf files are long- term residents of the queue. The content of these files, even of the qf files that contain queue control information, have no impact on the recipes in this chapter, and therefore, we won't describe the content of these files in any more detail. If you're curious about the internals of the qf file, see Section 11.11 of the sendmail book.

df , qf , xf , and tf are filename prefixes that identify the type of queue file. The full name of a queue file is composed of one of these prefixes followed by the unique queue identifier associated with an individual message. For example, this ls command lists all of the df files in the queue:

 #  ls df*  dfg7KEK4W9001253  dfg8Q82lkj002190  dfg8RDYB6v001254 

While this ls command lists all of the files associated with a specific mail message:

 #  ls *g8Q82lkj002190  dfg8Q82lkj002190  qfg8Q82lkj002190 

These ls commands are used to illustrate the structure of a queue filename. ls is not normally used to examine the queue. Use the mailq command to see what messages are queued.

By default, the sendmail.cf configuration uses the /var/spool/mqueue directory for the queue files. The submit.cf configuration uses /var/spool/clientmqueue as the default. However, several of the recipes in this book contain commands that change the default queue and create a more complex and flexible queue directory structure for the sendmail.cf configuration, and those same commands can be used in the submit.cf configuration.

The queue can be processed immediately by running sendmail with the -q commandline option. More typically, however, the -q option is provided with a time interval argument, which causes sendmail to process the queue periodically. For example, -q15m would process the queue every 15 minutes.

Timing, and not just the timing of how often the queue is processed, is part of the nature of a queue. After all, a queue is created to store undelivered messages for a specified amount of time. A sendmail queue also has timers for how often the sender is warned that the message is still undelivered and waiting in the queue. These timers can be configured for normal, urgent, and non-urgent messages. The timer options in the sendmail.cf file that relate to how long messages are held in the queue are:


Timeout.queuereturn

The Timeout.queuereturn option defines the amount of time a message is kept in the queue before it is returned to the sender as undeliverable. This option is configured by the confTO_QUEUERETURN define. This timer, which defaults to five days ( 5d ), applies to most mail messages.


Timeout.queuereturn.normal

This option defines the amount of time a message containing a Precedence : normal header is kept in the queue before it is returned to the sender as undeliverable. This option is configured by the confTO_QUEUERETURN_NORMAL define. The default is five days ( 5d ).


Timeout.queuereturn.urgent

This option defines the amount of time a message containing a Precedence : urgent header is kept in the queue before it is returned to the sender as undeliverable. This option is configured by the confTO_QUEUERETURN_URGENT define. The default is two days ( 2d ).


Timeout.queuereturn.non-urgent

This option defines the amount of time a message containing a Precedence: non-urgent header is kept in the queue before it is returned to the sender as undeliverable. This option is configured by the confTO_QUEUERETURN_NONURGENT define. The default is seven days ( 7d ).


Timeout.queuewarn

The Timeout.queuewarn option defines the amount of time sendmail waits before sending a warning message telling the sender that a message is still undelivered. This option is configured by the confTO_QUEUEWARN define. This timer, which defaults to four hours ( 4h ), applies to most mail messages.


Timeout.queuewarn.normal

This option defines the amount of time sendmail waits before sending a warning message telling the sender that a message containing a Precedence : normal header is still undelivered. This option is configured by the confTO_QUEUEWARN_NORMAL define. The default is four hours ( 4h ).


Timeout.queuewarn.urgent

This option defines the amount of time sendmail waits before sending a warning message telling the sender that a message containing a Precedence : urgent header is still undelivered. This option is configured by the confTO_QUEUEWARN_URGENT define. The default is one hour ( 1h ).


Timeout.queuewarn.non-urgent

This option defines the amount of time sendmail waits before sending a warning message telling the sender that a message containing a Precedence : non-urgent header is still undelivered. This option is configured by the confTO_QUEUEWARN_NONURGENT define. The default is 12 hours ( 12h ).

As an example, adding the following confTO_QUEUERETURN define to the sendmail configuration would reduce to three days the amount of time a normal message is allowed to remain in the queue before it is returned to the sender as undeliverable:

 dnl Return normal messages after three days in the queue define(`confTO_QUEUERETURN', `3d') 

Timing might be changed on any system. The recipes in this chapter, however, are primarily of interest to large sites that have large queues. On most systems, the queue is so small that the amount of time spent processing the queue is negligible. However, when the queue grows to tens of thousands of messages, significant time can be used on each queue run. If your system normally has a small queue of a few hundred or a few thousand queued messages, the default sendmail configuration is probably adequate. If your queue often grows to tens of thousands of messages, read on.



Sendmail Cookbook
sendmail Cookbook
ISBN: 0596004710
EAN: 2147483647
Year: 2005
Pages: 178
Authors: Craig Hunt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net