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:
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:
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. |