Comments on How To Delete Mails From Or To A Specific Email Address From Your Mail Queue (Postfix)
How To Delete Mails From Or To A Specific Email Address From Your Mail Queue (Postfix) If you get hit by a spam attack that floods your server with hundreds/thousands of emails from the same sender email address or to the same recipient email address, you can clean your mail queue from these emails with one single command before the mail flood takes your server to its knees.
25 Comment(s)
Comments
You should probably use tail -n +2 instead of tail -2 which is deprecated and does not work everywhere.
Hello, I've the same problem. more than 60000 mails is in the mail queue! and I can't delete it, handy. I use this command and after 1 second it will done without any error but it doesn't work.
mailq | tail -n +2 | awk 'BEGIN { RS = "" } / info@mail\.com$/ { print $1 }' | tr -d '*!' | postsuper -d -
It worked for me when I ran it this way:
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / byrdsnestquilt@bellsouth\.net/ { print $1 }' | tr -d '*!' | postsuper -d -
+1 for your Comment.
This Command works for me too on Debian Squeeze.
mailq | tail -n +2 | awk 'BEGIN { RS = "" } / mailbox@asd\.com.mx$/ { print $1 }' | tr -d '*!' | sudo /opt/zimbra/postfix/sbin/postsuper -d -
mailq|fgrep [email protected]|sed 's/\*.*//'|sudo /opt/zimbra/postfix/sbin/postsuper -d -
this command works for me.
This worked for me (taken from above). 12/18/2018. Thanks Dan.
/opt/zimbra/postfix-2.7.10.3z/sbin/postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / Joe@Blow\.com/ { print $1 }' | tr -d '*!' | sudo /opt/zimbra/postfix/sbin/postsuper -d -
Works on wheezy
This was the only one that worked for me on RHEL
This worked like a charm - 18k emails - 2secs.
Ubuntu - CentOS
+1 thank you for this comment as well. Worked for me on a CentOS 6.8 server
Works perfectly!
Thanks
worked for me as well
For me works this
mailq | tail -n +2 | awk 'BEGIN { RS = "" } / info@mail\.com$/ { print $1 }' | tr -d '*!' | sudo postsuper -d -
The above commands are not working
For deleting email from some domain, you can use
<code> mailq | awk '$7 ~ /@domain.tld$/ { print $1 }' | tr -d '*!' | postsuper -d -</code>
for deleting email from specified user, use
<code>mailq | awk '$7 ~/^[email protected]$/ { print $1 }' | tr -d '*!' | postsuper -d -or for </code>
this one works for me on debian ... THANX
postsuper -d <queue id> works much more easily.
get the id from postqueue -p:
8D609414BFF4 9564 Fri Feb 27 10:42:42 [email protected]
(conversation with mail.owlpic.com[64.38.116.11] timed out while receiving the initial server greeting)
So in this case
postsuper -d 8D609414BFF4
If you have just one or two mails, then yes. If you have o clean up a few thousand spam mails, then its more handy to use a script like the one above.
Nice for Postfix, but how do I do that with SENDMAIL?
Somehow your solution didn't work for me. However, what did work is this:
mailq | grep -E "^[A-Z0-9]+" | grep [email protected] | cut -c1-12 | postsuper -d -
a liitle bit eassier: mailq |grep -i [email protected] |cut -c1-10 | postsuper -d -
THIS ONE IS THE ONLY ONE THAT REALLY WORK ON POSTFIX
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / abcde@xyz\.net/ { print $1 }' | tr -d '*!' | postsuper -d -
I am having Mac OS X Server. I have faced spamming issues several times. It shows few thousands emails in the mail queue (sudo mailq). When firing sudo postfix -d ALL , it doesn't give any output like xxx messages deleted.
@tattwam On Mac OS X Server, you must specify the full path inside of the Server.app package when invoking the "post*" commands (mailq does not require the path). So if you wanted to invoke... postqueue -p ...on OS X Server, you would invoke... /Applications/Server.app/Contents/ServerRoot/usr/sbin/postqueue -p If you don't include the path, it tries to use the wrong queue and you'll get invalid (empty) results. If you have a command like the mailq command above that invokes "postsuper -d" at the end, just paste in that same path just before postsuper, so the command above would end up as: mailq | tail +2 | awk 'BEGIN { RS = "" } / falko@example\.com$/ { print $1 }' | tr -d '*!' | /Applications/Server.app/Contents/ServerRoot/usr/sbin/postsuper -d -
I just used this...
mailq | grep username | cut -c1-12 | postsuper -d -