Tags: queue lifetime
Adjusting QMail retries and max queue lifetime
by Chris Walker on Sep.20, 2010, under Technical, How To, General, Skills, Email, Linux, Unix, Software, QMail, QMail
Recently at work I discovered that our servers can take up to a week to process a bounce-back message depending on the error code. Turns out that 4.4.* errors tend to cause this. These errors are usually because the receiving mail server is under heavy load or is not reachable at the time.
Follow up:
Qmail, by default will retry for 7 days, 1 hour (604800 seconds) before finally returning a bounce message. Unfortunately this means that users assume that the recipient got the message and was not responding to it. To counter this, QMail has a setting called queuelifetime. This is a configurable option in QMail and can provide a better response time to your users before having to respond to messages about why their messages are not being replied to, or are getting bounces from over a week ago.
First, from the man pages of qmail-send:
queuelifetime
Number of seconds a message can stay in the queue. Default: 604800 (one week). After this time expires, qmail-send will try the message once more, but it will treat any temporary delivery failures as permanent failures.
This configuration file belongs in /var/qmail/control [at least on linux servers/systems]. To add this file do the following: (#: indicates command line command)
Open a calculator, and input: [number of hours to wait before bouncing, 48 in this case] * 60 * 60This gives you a number of seconds before bouncing (172800 seconds)
#: $EDITOR /var/qmail/control/queuelifetime
Add the number you got from a calculator into this file. No other information, ensure that as few newlines are at the end of the file as possible, save and exit
#: /etc/init.d/qmail restart
The queuelifetime has been set, below is how to verify
Create a message from a user on this server. and send it to something like: you@www.mydomain.tld. Make sure that this (sub)domain does not have a(n) SMTP daemon running.
#: less [path to maillog]
Search (by typing / followed by you@www.domain.tld ex: /you@www.domain.tld) for the message ID, it should look similar to this:
Sep 20 12:53:09 glacier qmail: 1285008789.632721 starting delivery 11123: msg 9199985 to remote codeninja@nyx.devnetonline.net
Note the msg [number] this is the message number you will use. Now we will go to the qmail queue directory
#: cd /var/qmail/queue/info/
Find the message by the ID specified [9199985 here] #: find ./ -type f -name "9199985"
This will return a path like ./21/9199985, now, we do the following to cause it to expire, note that this will vary depending on your time, but we can generalize this from the log entry underlined above
#: touch --date="Sept 18 11:00:00" /var/qmail/queue/21/9199985
If you have patience, wait 5-10 minutes after doing so and check your mail. If not, run qmail-send to process the queue immediately. You should see a bounce back message. If you do not it may not have been processed yet, or the queuelifetime file was not checked and used. You can check to make sure by again touching the file but specifying a week ago instead of the time specified in the queuelifetime configuration file. [~48 hours in our case]. If you see the bounce back. You are done and you get a plate full of cookies!
The above guide should help for most qmail servers, however some syntax may differ. This was performed using a CentOS server. Check your manuals for more information and help
.