Postfix is one of the most common open-source mail transfer agents (MTAs), and is the one we run for ourselves and clients. Like just about every other MTA, once Postfix accepts an email from any source, it places the email in a queue. Another Postfix process then runs through the queue and processes the email according to the Postfix settings (typically deliver it to a local mailbox, spamassassin or an outside mail server).
Types of Mail Queues
- maildrop The maildrop queue is the temporary queue for all incoming mail from the local server. Messages submitted directly to the maildrop or sendmail scripts are placed here until they can be added to the active queue.
- hold The hold queue is basically a quarantine queue created by changing access restrictions from Postfix settings. Normally this queue is not used unless explicitly setup by the admin.
- incoming Emails arriving are placed in the incoming queue immediately upon arrival. Normally once an email hits the incoming queue it is sent to the active queue, however this is dependent upon the resources available to the active queue.
- active Emails which have yet to be delivered due to resource restrictions are placed in the active queue. This is the only memory queue, where the other queues operate with a file on the hard-disk.
- deferred Emails which could not be delivered but where not necessarily bounced are placed in the deferred queue for future deliver.
Mail Queue Operations
Viewing a Queue
An individual queue can be viewed with the mailq command.
~ mailq
~ QUEUE_ID MSG_SIZE ARRIVAL_TIME SENDER RECIPIENT,RECIPIENT...
The mailq command outputs a table with the queue ID, message size, arrival time, sender and outstanding recipients.
Flush Queue
Flushing the queue forces the mail queue manager to attempt to process and deliver every message in the queue. Unless the active queue crashed, you typically will only flush the deferred or hold queues since the other ones seldom have messages for longer than a few seconds.
~ postfix flush
Clear Queue
Clearing the queue forces the mail manager to delete all the messages in the particular queue.
~ postsuper -d QUEUE
Substitute QUEUE for the mail queue you want to clear, or 'ALL' to delete all the messages in all the queues.