Delete messages in Queue

dthompson

Well-Known Member
Nov 23, 2011
146
16
58
Canada
www.digitaltransitions.ca
I would like to know if there is a way to only delete certain messages in a queue en mass.

I have some messages building up in the queue but I don't necessarily want to delete them all, only the ones that I know are dead and will go no where.

Is there anyway for me to granularly delete specific emails stuck in the queue but many of them at once as opposed to deleting all the emails, including the ones I do not want to delete?
 
You can use mailq and postsuper commands for the same. Take a look at - easyengine.io/tutorials/mail/postfix-queue/
 
I would like to know if there is a way to only delete certain messages in a queue en mass.

I have some messages building up in the queue but I don't necessarily want to delete them all, only the ones that I know are dead and will go no where.

Is there anyway for me to granularly delete specific emails stuck in the queue but many of them at once as opposed to deleting all the emails, including the ones I do not want to delete?

You can to try this:

find /var/spool/postfix -type f | xargs -n 1000 grep -l @anydomain.com | sed 's/.*\///g' | postsuper -d -

find /var/spool/postfix -type f | xargs -n 1000 grep -l anyemail@anydomain.com | sed 's/.*\///g' | postsuper -d -

Regards!