This is an old revision of the document!
http://gnufreakz.wordpress.com/2010/06/08/postfix-queue-management
http://blog.gtuhl.com/2008/08/14/basic-postfix-queue-management
http://postfixmail.com/blog/index.php/manage-mail-in-the-deferred-queue/
These systems use Postfix as the MTA:
postqueue -p
View a particular message:
postcat -q <queueID> | head --lines 100
grep "Nov 13 06:13:" /var/log/maillog* grep "D233911382F9" /var/log/maillog*
Attempt to send queued mail now:
postqueue -f
View a deferred message:
postcat -q 022412012A | head -40
or:
postcat /var/spool/postfix/deferred/0/022412012A
Delete all queued mail:
postsuper -d ALL
Once you list queued messages with postqueue -p
and determine a reg-ex pattern of files you want to delete, you can use the following script to do the deletions.
The following script deletes all mail from the any queue which matches the regular expression specified as the first argument.
#!/usr/bin/perl $REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!\n"; @data = qx</usr/sbin/postqueue -p>; for (@data) { if (/^(\w+)(\*|\!)?\s/) { $queue_id = $1; } if($queue_id) { if (/$REGEXP/i) { $Q{$queue_id} = 1; $queue_id = ""; } } } #open(POSTSUPER,"|cat") || die "couldn't open postsuper" ; open(POSTSUPER,"|postsuper -d -") || die "couldn't open postsuper" ; foreach (keys %Q) { print POSTSUPER "$_\n"; }; close(POSTSUPER);
For example, to delete all queued messages from or to the domain called fackspamdomain.com
, enter:
./postfix-delete.pl fackspamdomain.com
Delete all queued messages that contain the word “xyz” in the e-mail address:
./postfix-delete.pl xyz