fbpx

How to delete messages from the Postfix queue using the command line

You can either use Webmin or the command line to delete Postfix messages in the queue.

Typically you have to resort to this remedy when you’re Postfix system has been spammed.

Of course you want to also find the root cause of the breach but that’s another article and matter entirely.

Webmin might be slow, so rather use the command line.

To cut to the chase, the command you should use is:

postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } /vtext\.com/ { print $1 }' | tr -d '*!' | postsuper -d -

Replace the text between “/” and “/”, ie. replace vtext\.com with whatever probably FROM or TO address you want to remove.

It also works for MAILER-DAEMON which will be in the 100s or 1000s after a spamming incident:

postqueue -p | tail -n +2 | awk ‘BEGIN { RS = “” } /MAILER-DAEMON/ { print $1 }’ | tr -d ‘*!’ | postsuper -d –

To delete all message in the queue,  do this:

postsuper -d ALL

Reference:

https://www.emailquestions.com/threads/how-to-delete-all-email-from-a-domain-or-one-email-address.9369/

Share this article

Share on facebook
Share on twitter
Share on linkedin

Leave a Reply

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

Scroll to Top