Remove All Messages from Postfix Queue

postfix-mysza.gif
Postfix.org – Mail Server

I’ve been decommissioning some old servers recently and this generated quite a bunch of monitoring alerts. So many, in fact, that I have maxed out the free Sendgrid plan I use for sending email alerts. Part of the troubleshooting involved working with Postfix mail server queue, I figured some of you might find this useful.

How To Show Postfix Queue

I wanted to review messages in Postfix mail queue to understand if there was indeed an issue with my free Sendgrid account:

root@m:/ # postqueue -p | less
...
D2704A84E3 604 Wed Feb 6 14:46:31 [email protected]
(delivery temporarily suspended: SASL authentication failed; server smtp.sendgrid.net[159.122.219.55] said: 451 Authentication failed: Maximum credits exceeded)
[email protected]

D0842A7563 587 Sun Feb 3 20:30:07 [email protected]
(delivery temporarily suspended: SASL authentication failed; server smtp.sendgrid.net[159.122.219.55] said: 451 Authentication failed: Maximum credits exceeded)
[email protected]

D36ABA77F6 546 Mon Feb 4 12:39:23 [email protected]
(delivery temporarily suspended: SASL authentication failed; server smtp.sendgrid.net[159.122.219.55] said: 451 Authentication failed: Maximum credits exceeded)
[email protected]

...

-- 7631 Kbytes in 6971 Requests.

Ouch! Almost 7 thousand emails which I’ll never get (in reasonable time) and don’t really need (I know the reason for alerts). So what do to? Let’s destroy these.

How To Remove All Messages from Postfix Queue

I’ll use the postsuper command and specify option d (means delete) and ALL (means REALLY DELETE ALL MESSAGES IN MY QUEUE):

root@m:/ # postsuper -d ALL
postsuper: Deleted: 6971 messages

That’s much better:

root@m:/ # postqueue -p
Mail queue is empty

That’s it for now! Hope you enjoyed this short article. Let me know if you’re using Postfix mail server!

See Also