How to cleanout your postfix queues by sender

/, Linux, Spam/How to cleanout your postfix queues by sender

How to cleanout your postfix queues by sender

This post is mostly to help me remember how to do this, if the situation arises again.

I just had a lot of mail backup on my server. The 10MinuteMail inbox was over 300 MB (usually it kept below a megabyte), Postfix’s active queue was maxed out at 20,003 entries (why the 3, I don’t know), and the incoming queue was another 20,000+. Basically everything was all backed up. I’m not 100% sure how this condition gets started. I’ve seen it a few times on my old server when super high volumes of incoming mail deliveries combined with other sites I hope serving up high bandwidth to end users. This is the first time it’s happened on the new server. It may be time to change out the domain that the 10MinuteMail e-mail addresses are using.

Regardless, using qshape I was able to identify a handful of from addresses (presumably either spammers or a cyclic bounce issue) which accounted for over 8,000 of the mail in the active queue. By using the following command I was able to purge out just those messages from the queue:

mailq|awk ' /^[0-9A-F][0-9A-F]*.*$/ {print $1}'|tr -d '*'| xargs -rn1 postsuper -d

Where is the domain, or from address you wish to delete. This works pretty well. I may whip up a bash script to handle this in the future.

For reference, the worst offenders are:


Why so many from Japan? I have no idea….

By |2007-05-29T11:35:12+00:00May 29th, 2007|10MinuteMail, Linux, Spam|5 Comments

About the Author:

Devon is a husband, amateur photographer, avid reader, and motorcycle enthusiast.


  1. Devon July 21, 2008 at 6:33 pm - Reply

    qshape command: qshape -s active

  2. Devon November 1, 2010 at 6:43 am - Reply

    Also, to delete items from the queue(s) based on the to address:

    mailq | tail -n+2 | awk ‘BEGIN { RS = “” } { if ($8 == “[email protected]” && $9 == “”)print $1 }’ | tr -d ‘*!’ | postsuper -d –

  3. Heaje July 25, 2011 at 5:48 am - Reply

    Thanks for posting this. It just saved me a whole lot of trouble…..

  4. Dominios BR December 3, 2013 at 7:44 am - Reply


  5. Desktop Masters September 4, 2014 at 11:58 am - Reply

    This was an AWESOME solution. Saved me loads of time. One of my clients accounts got hacked and we had over 50,000 messages in the queue. This cleaned it right up!!

Leave A Comment