Delete Specific Messages in Postfix Queue

By November 28, 2012Sample Work

With this simple command you can delete specific messages that are in your Postfix queue.  In this case of a spam attack this is an invaluable command, as you can cleanup the queue of the offending messages.

Enter any text string and this command will hunt the messages and delete them.

First, check what is in the queue with:

[raw]mailq[/raw]

Then run the command, making sure to change REPLACEME to the string you search and delete messages for.

[raw]mailq | tail -n +2 | awk ‘BEGIN { RS = “” } / REPLACEME/ { print $1 }’ | tr -d ‘*!’ | postsuper -d -[/raw]

Leave a Reply