On this page
Postsuper: Mass Deletion of Emails in the Queue
Introduction
Postsuper is a Postfix utility that allows you to delete emails in the queue. I needed it to delete around 40,000 emails that were error messages from the MAILER-DAEMON user, with approximately 300 emails in the batch that needed to be delivered.
Complete Deletion
To delete all emails in the queue:
postsuper -d ALL
Partial Deletion
To delete all emails from the MAILER-DAEMON user, here’s the script (replace MAILER-DAEMON with another name if needed):
#!/bin/sh
supp=`mailq | grep MAILER-DAEMON | awk -F"*" '{ print $1 }'`
for i in $supp ; do
postsuper -d $i
done
Or alternatively, here’s another example:
mailq | tail +2 | awk 'BEGIN { RS = "" } / user@mydomain\.com$/ { print $1 }' | tr -d '*!' | postsuper -d -
Last updated 15 Jan 2008, 19:45 +0200.