Postfix Queue Maintenance

From time to time its necessary to carry out maintenance on Postfix’s queues, especially after a massive influx of spam or mail queue issues.

This command will delete one specific email from the mail queue (taken from the postsuper man page):

#mailq | tail +2 | grep -v ‘^ *(‘ | awk  ‘BEGIN { RS = “” } { if ($8 == “[email protected]” && $9 == “”) print $1 } ‘ | tr -d ‘*!’ | postsuper -d –

Note that “[email protected]” should be replaced with the messages noted email address.

To clear (delete) the entire Postfix queue, run the following command:

#postsuper -d ALL

Note: This command will delete all messages in the Postfix queue. If you need more selective deleting, this can be done as well, use ‘man postsuper’ to find out all of the available options.