Postfix: flush emails from the mail queue

Problem:

The customer was getting a lot system alerts even after disabling it. There were a lot of emails in the queue:

# mailq
-Queue ID-  --Size-- ----Arrival Time---- -Sender/Recipient-------
DB13ED78461   21597 Thu May 26 05:39:26  flashgrid@localhost.localdomain
(delivery temporarily suspended: connect to us-smtp-inbound-2.meme.com[~]:25: Connection timed out)
                                         alertdb@test.com

DA31AD9C4B5   21503 Thu May 26 10:32:16  flashgrid@localhost.localdomain
(delivery temporarily suspended: connect to us-smtp-inbound-2.meme.com[~]:25: Connection timed out)
                                         alertdb@test.com

DA701D9AC16   21601 Thu May 26 07:01:06  flashgrid@localhost.localdomain
(delivery temporarily suspended: connect to us-smtp-inbound-1.meme.com[~]:25: Connection timed out)
                                         alertdb@test.com

DA3B9D9C488   21503 Thu May 26 09:31:36  flashgrid@localhost.localdomain
(connect to us-smtp-inbound-1.meme.com[~]:25: Connection timed out)
                                         alertdb@test.com

[...]

Solution:

  • To remove all mail from all the queues ( hold, incoming, active and deferred ) , run :
# postsuper -d ALL
  • To remove all mails in the deferred queue only, run :
# postsuper -d ALL deferred