Wednesday, March 1, 2017

Cleanup a postfix mail queue




  1. Do you need to cleanup a postfix mail queue?

    To delete all email from one specific email address, or all email From: a specific domain name, please choose the appropriate command from the following list.

    To delete all email in the queue from a domain run this command as root:

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

    To delete all email in the queue From: a specific email address run this command as root:

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


    To delete ALL email from the queue regardless of domain name or email address use:


    postsuper -d ALL