Delete Spam from Exim Queue

June 5th, 2007 by Sameer | Filed under Hosting.

Spam is a major cause of headache for many people in the world.  Especially server administrators.

Here is a tip to clean up your exim mail queue if its getting to large and full of spam.

Please keep in mind that some legitimate emails may get deleted by this method.  Please use it carefully.  I had more than 2000 emails in my queue, and it was reduced to about 50 after running a few of these.

First, run

 grep -R -l [SPAM] /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm

The highlighted word will be used in a grep search and replace and all messages matching that will be deleted.  If you also want to remove frozen messages from your queue, run the following

grep -R -l ‘*** Frozen’ /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm

You can perform one more that will also clean your exim queue some more

grep -R -l ‘The recipient cannot be verified’ /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm

Second tip – if you are using CPanel, set up your mails to default to :fail: rather than :blackhole:

References:

 

Other Interesting Posts

2 Responses to “Delete Spam from Exim Queue”

  1. Osama says:

    plz i have problem in my exchange server 2003 i can’t send any mail to outside it’s give me this error

    The following recipient(s) could not be reached:

    samos.256@hotmail.com on 23/02/2009 04:06 ?
    There was a SMTP communication problem with the recipient’s email server. Please contact your system administrator.

    i need to solve it soon i can’t delete the spam in my queue

    plz help

  2. just had a user account password stolen by spammers, had thousands of messages in the queue. worked like a champ, thanks. :)

Leave a Reply