Chapter 6: Configuring Spam Prevention System and Antivirus Agent Up Main page Chapter 8: Command-Line Log Analysis Tools 

7 The Mail Queue

figure images/nodeworx/nw-email-queue.png
Figure 7.1 The NodeWorx Mail Queue Settings Page

7.1 qmail Queue

qmail’s core feature is its queue, a parallel mail processing environment that allows simultaneous transmission of, by default, 20 messages at any given time. The queue can even operate reliably over NFS without locking, permitting clustered InterWorx servers to each transfer mail in parallel.

7.1.1 Remote

The qmail remote queue feeds the MTA end of qmail - where messages go to leave the system. Any mail destined for a remote machine is placed into the Remote queue, and transmitted the next time the queue processes.

7.1.2 Local

Much as the Remote queue works for sending messages along to other machines, The Local queue arranges for deliveries via the two MDAs, passing messages on to them to be filed into the users’ Maildir directories on the local machine.

7.1.3 Todo

The Todo queue contains the envelope for each message in the Local or Remote queues. When enough messages have built up in Todo or a set quantity of time has elapsed, a signal is sent to qmail to process the queue.

7.2 Options and Diagnostics

7.2.1 Statistics

The Statistics block gives you a quick overview of the Local, Remote, and Todo queues, as well as the ability to purge one or all of them. Note: Purging the queue is NOT the same as processing the queue - Purging deletes all messages.

7.2.2 Processing

An option is given here to manually signal qmail to process the mail queue. Only use this option if the mail queue doesn’t appear to be processing on its own.

7.2.3 Testing SMTP Through Queue

The form in this block exists to allow a quick test of the qmail-inject, qmail-queue, and qmail-smtp software, dropping a message directly into the queue to debug and test sending.

7.3 Queue Failures

The qmail queue system is one of the more robust features of qmail. It is designed to be very reliable in that messages will not get corrupted nor will they get lost even due to a hard crash (unless the filesystem the queue lives on gets lost in which case you’ve got bigger problems).
Occasionally there can be problems with the queue. The queue is very delicate in that it should never be manipulated by an actual server administrator unless they understand the internal structure of the queue very well. The only things that should be manipulating the queue are the programs which comprise the qmail suite. As a result, InterWorx typically recommends that you simply dump the current queue and reset it when the queue is broken in order to get the mail system working again. [V][V]Part of the reason that manipulating the queue manually with cp/mv/rm commands is a bad idea is because the queue files are named based on the filesystem inode number - which obviously would change if you started moving stuff around. Not to mention qmail expects certain files to be in certain directories of the queue in order to know what state a message is in. An incorrect file state will lead to strange behavior - possibly the queue corrupting itself further.

7.3.1 Resetting Queue

The qmail queue can be checked by visiting System Services  ▷  Mail Server  ▷  Mail Queue. Ideally you should rarely have to do this. It can be useful if you know that the permissions, timestamps, or other file attributes of the queue have been modified by something other than qmail programs and you are having issues sending/recieving mail. Additionally, if you are sitting on a large (1000+) set of spam messages in the remote queue this can stop that mail from being sent out. Keep in mind this will also affect legitamate mail sitting in queue. Thus, if you have many legitamate customers using mail constantly, resetting the queue is not the recommended way to clear out spam.
In any case, this procedure just moves the current queue out of the way such that it can be inspected later for legitimate mail “caught in the storm” so to speak:
  1. cd /var/qmail - Change to the directory where the qmail queue exists.
  2. service smtp stop - Stop the qmail-smtp service.
  3. service send stop - Stop the qmail-send service.
  4. mv queue queue.bad - Move the damaged queue into a folder for later analysis or message recovery.
  5. yum reinstall qmail - Reinstall qmail, which automatically sets up a new queue with the appropriate parameters. This command does not change any of your qmail settings.
  6. service smtp start - Restart the qmail-smtp service.
  7. service send start - Restart the qmail-send service.
With that, your queue should be completely refreshed and ready to run again.
 Chapter 6: Configuring Spam Prevention System and Antivirus Agent Up Main page Chapter 8: Command-Line Log Analysis Tools 

(C) 2019 by InterWorx LLC