Sendmail Queue

10:43 PM

When submitting mail by using sendmail as a mail submission program, sendmail copies all messages to "/var/spool/clientmqueue" first. Later, another sendmail process, the sendmail mail transfer agent (MTA) copies the messages from /var/spool/clientmqueue to /var/spool/mqueue and sends them to their destination.
/var/spool/clientmqueue is thus the holding area used by the MSP (Mail Submission Protocol) sendmail instance before it injects the messages into the main MTA (Mail Transport Agent) sendmail instance. Sendmail will save the message in /var/spool/clientmqueue for safe keeping before trying to connect to the MTA to get the message delivered.
When files accumulate in /var/spool/clientmqueue, this is probably due to sendmail localhost MTA not running, and thus the mails don't get send.
Basic mailq commands:
  • Following command show the mail submission queue ( note that this is not the amount mail in queue but waiting to be processed by queue runner)
# mailq -v -Ac
/var/spool/clientmqueue is empty
                Total requests: 0
  •  Following command shows total mails in queue.
# mailq | grep -i total
                Total requests: 1166
Following command shows total lost emails (to understand what lost emails are, please continue to read this article)
# mailq -qL | grep -i total
                Total requests: 17178

Note : One may alternatively use "sendmail -bp"  command that will also display mails in queue.

Parts of message queue

Files stored in the queue directory (/var/spool/mqueue) are identified by the first two letters.
df - data file -  Indicates data files or content of queued message.
qf - queue control file - Indicates headers of queued message
Qf  - bogus qf file - Indicates headers of permanently queued message or lost message.
Another two not very important (from a user perspective) parts of message are
tf - temporary qf rewrite image -  When processing a queued message, it is often necessary for sendmail to modify the contents of the qf file. This usually occurs if delivery has failed or if delivery for only a part of the recipient list succeeded. In either event, at least the message priority needs to be incremented.To prevent damage to the original qf file, sendmail makes changes to a temporary copy of that file. The temporary copy has the same queue identifier as the original, but its name begins with a t.
xf - transcript file - While calling the necessary delivery agents, sendmailsaves all the error messages it receives in a temporary file. The name of that temporary file begins with the letters xf. After all delivery agents have been called, sendmail returns any collected error messages to the sender and deletes the temporary xf file.

Understanding qf in detail

The qf file contains the message header. In addition to the header, the qf file also contains all the information necessary to:
  •  It contains the sender's address and a list of recipient addresses.
S<root@10-163-120-13.cloud.opsource.net>
  •  It contains a priority that determines the current message's position in a queue run of many messages.
P7140439
  •  It contains the date that the message was originally queued. That date is used to time out a message.
 Fri, 21 Jan 2011 00:35:01 -0500
  •  It contains the reason that the message is in the queue and possibly the error that caused it to be queued.
MDeferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.

What are lost emails

Sendmail renames a qf file to Qf if there is a problem that it cannot address it by merely deferring or rejecting it, its often called lost emails. An example, would be like we have a email address no-reply@domain.com which has sent a email to a valid user but its not able to reach the receiving server, so it keeps deferring it until 5 days when it permanently rejected and sendmail tries to notify sender no-reply@domain.com that it cannot deliver but it simply fails to notify as  no-reply@domain.com isn't a valid address. Since it cannot notify, it just gives error:
SYSERR(root): savemail: cannot save rejected email anywhere
savemail panics occur when sendmail is unable to deliver a bounced message and keep it as Qf file in mqueue directory.
Most of these Qf fails can be deleted, but at times there can be genuine email that could have failed to deliver. Though sendmail would not rename it back from Qf to qf to deliver, with human intervention, one can rename the failed Qf message to qf and retry it to see if it delivers.
There are also some df files that may not have any associated qf or Qf file which can be deleted as well (very few or negligible).
#!/bin/bash
# Script to delete  Qf and its associated df
# Inform and take customer permission before running this script.
cd /var/spool/mqueue/
for i in `ls Qf* | cut -c3-`
do
   rm -v *$i
done

Flushing Sendmail queue or running queuerunner

Following command will try to forcefully run the mailq:
/usr/sbin/sendmail -q -v

You Might Also Like

0 comments

Contact Form

Name

Email *

Message *

Translate

Wikipedia

Search results