How to Delete Mail Queue in Postfix

Last Updated on: 

I had some issue with one of mailserver, where postfix keeps retrying to send mail to a mistyped email address, it was very frustrating considering this particular email was holding back thousands of email, this how I solved it:

To delete a mail queue in Postfix, you use the postsupercommand, which is used for postfix mail queue related stuff, note that it can only be run by superuser of the system.

Before you delete a mail in the queue, you’ll want to check if there is any mail in the queue at all, you can check by using the mailqcommand, for example, I was trying to send a mail to multiple users, and let’s assume it’s not going through, you are gonna see something that looks similar as below:

					

-Queue ID-  --Size-- ----Arrival Time---- -Sender/Recipient-------
7483D5CB40*     851 Thu Jul 16 11:53:40  user@gmail.com
                                         user@gmail.com
                                         user@yahoo.com

-- 0 Kbytes in 1 Request.

Note: The reason why I have multiple ‘Sender/Recipient’ above is that I am sending a single mail to multiple addresses, just the way you can add multiple emails when sending in an email client, e.g Gmail.

Now, to remove a mail queue, you note the -Queue ID-, and you then use the following command:

					

postsuper -d Mail_Queue_ID

Remove All Mails from Queue

This is where you would have multiple mails with different user, for illustration purpose, see below example:

					

-Queue ID-  --Size-- ----Arrival Time---- -Sender/Recipient-------
7483D5CB40*     851 Thu Jul 16 11:53:40  user@gmail.com
                                         user@gmail.com
                                         user@yahoo.com

9483E5CB40      851 Thu Jul 16 11:53:40  anotheruser@gmail.com

4483W5CB40      851 Thu Jul 16 11:53:40  bob@gmail.com

-- 0 Kbytes in 1 Request.

You can see the above all have a different Queue ID, to clear them all, you use the following command:

Remove only All Deferred Mails In Queue

If you notice at the start of this guide I said, I had issue with some invalid recipient address, here is the deal:

The differed mail queue holds all messages or mails that have soft-failed (temporary failure), and need to be retried, in most case the failure can be due to invalid recipient address, or greylisting by spam filters.

If you want to delete only the differed mail queue, you use the following command:

Enjoy.

Comment policy: Respectful and beneficial comments are welcome with full open hands. However, all comments are manually moderated and those that doesn't relate with what the passage is saying or offensive comments would be deleted. Thanks for understanding!

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php