Script to delete the mail queue Postfix
A few months ago, a client with a Postfix mail server running on RedHat (or Debian, I do not remember) began to have problems with the mail queue (tail-mail). Apparently a user's PC was infected with some Spambot, which was sending a huge amount of spam via the mail server of the company.
Vaccinate the infected PC was only the beginning, because in the tail of the Postfix MTA were still the +20000 mails that had sent the spam bot, to do to erase all of those e-mails?
On the one hand the server was working at full capacity to process the mail queue, this includes spam and legitimate emails from other users.
So to be able to work quietly down the demon of postfix on Redhat (CentOS, Fedora, SuSE) running the following command:
postfix.redhat: ~ # postfix stop service If you use Debian (Knoppix, Ubuntu, etc) can download the service postfix well;
postfix.deathbian: ~ # / etc / init.d / postfix stop Already with the mail server off, we created the file / root / postfix_queue.sh with the following contents:
mailq | tail +2 | grep-v '^ * (' | awk 'BEGIN (RS = "") # 7 = $ sender, $ 8 = recipient1, $ 9 = recipient2 (If ($ 8 == "user@guatewireless.org" & & $ 9 == "") print $ 1) '| Tr-d' *! " | Postsuper-d --
Then we execute permission:
postfix.deathbian: ~ # chmod 755 / root / postfix_queue.sh | file: / root / postfix_queue.sh |
mailq | tail +2 | awk 'BEGIN (RS = "") # 7 = $ sender, $ 8 = recipient1, $ 9 = recipient2 (If ($ 7 == "usuario.spam guatewireless.org @" & & $ 9 == "") print $ 1) '| Tr-d' *! " | Postsuper-d -- |
And of course we run our script,
postfix.redhat: ~ # / root / postfix_queue.sh And seeing as automagically disappear thousands of correso of the tail.
So when they suffer another attack of spam, with the help of the script above and can eliminate the tail of the Postfix mail easily. By the way, if someone uses this script, that makes me a favor and go out of it, because I do not use postfix, good and not let my filters or viruses or spam.
Popularity: 18% [?]
2 comments to "Script to delete the mail queue of Postfix"
Trackback URI | Comments RSS



on 09 Nov 2007 at 1:42 pm # Jorge Andres
Apart from deleting the queue for mail and vaccinate the customer, you should configure your mail server does not relay, but will only send mail from authenticated users,
Put a firewall or a DMZ that filters traffic between your mail server and clients could also prevent the entry and exit of spam
slds,
[Reply]
on 05 Sep 2008 at 3:22 am # Conrad Casanto
I do not understand very well the meaning of the article.
What makes this script, which is in "man postsuper", is glued to delete the messages with a given address.
If you want to delete the queue, why do not postsuper-d ALL?
[Reply]