Postifx: delete mails in queue from a specific domain (or TLD)

Quick tip for managing postfix’s mail queues. A customer uses an old mailing software and he got subscription of unknown domains, which then remains in queue for long time. To purge a single domain from your mail queue use the following command:

mailq | grep -B3 "\.ovh$" | grep "^[0-9A-Z]" | cut -f 1 -d ' ' | xargs -n 1 postsuper -d

this will delete all mails in queue for the TLD .ovh.
Continua a leggere