Thursday, April 2, 2009

Delete email from postfix queue containing XXX

I don' t know why no one would just put this simple info out on the web.  Here is a brain dead search and delete of the postfix queue.  It is not fast nor cool, but it works.

find /var/spool/postfix | xargs grep -l "your string" | sed -g 's|.*/||' | postsuper -d -

I am such a UNIX scripting wimp.  This should have been so easy...  Maybe that is why it wasn't on the net... ;-)

Some other aliases that answer missing postfix functions (bash):

Delete all emails with sent by the argument email address:
function delfrom() { mailq | grep "$1" | sed -g 's|\ .*$||'| postsuper -d - ;}

How many emails are in the queue going to a given host:
function hostq() { mailq | grep "\@$1" | wc -l ;}

0 comments: