Postfix Queue Management
Retry delivery of mail in queue :
postqueue -f
Flush mail for a domain to primary mail server from Relay server:
postqueue -s domain.com
Delete all email in queue for a domain:
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } /@example.com/ { print $1 }' | tr -d '*!' | postsuper -d -
Delete all email in queue for an email address:
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } /email@example.com/ { print $1 }' | tr -d '*!' | postsuper -d -
Remove all Mailer Daemon Emails From Mail Queue :
for emailID in mailq | grep '^[A-Z0-9]' | grep 'MAILER-DAEMON' | awk '{print$1}'| tr -d '*!'
; do postsuper -d $emailID; done
Remove all Emails with specific string from mail queue :
for emailID in mailq | grep '^[A-Z0-9]' | grep -i 'STRING' | awk '{print$1}'| tr -d '*!'
; do postsuper -d $emailID; done
Remove all Email to an address from the mail queue :
mailq | tail -n +2 | awk 'BEGIN { RS = "" } / pedro_cesar7@hotmail.com$/ { print $1 }' | tr -d '*!' | postsuper -d -