Postfix stores messages in a mail queue before actually sending it. Sometimes a message can’t be sent and in that case you can access the queue and remove it manually.
Display the messages in the queue
To see which messages are currently in the queue:
This will result in something like this:
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- BF74A87146 333 Tue Mar 10 08:30:45 [email protected].com (temporary failure) [email protected].com -- 0 Kbytes in 1 Request.
In this example a mail from
[email protected] to
[email protected] got temporarily stuck in the queue.
Flush the queue
To flush the mail queue under
postfix you simply do this command:
This will process the queue, trying to deliver the remaining messages. If the message is not delivered but requeued instead, it is time to check the logs for any error messages.
Remove queued messages
If you just need to remove a single message, this is the command you need:
postsuper -d MAILID
MAILID is the ID of the mail in the queue.
To clean up the queue completely, you can remove the messages using this command:
postsuper -d ALL
This is a script floating around the internet for who knows how long. It will delete only the messages that match the specified regular expression.
The following commands will delete any message that contains either
root in the e-mail address:
./delete-from-mailqueue.pl example.com ./delete-from-mailqueue.pl root