A simple spam fighter!!

How frustating is it when you read a mail which you don’t want to. If you are getting mails saying that there’ll be guitar classes soon OR voluneteers are required OR someone lost/found watch/pen/diary/notebook etc. OR the real spams. By “The real spams” I mean the mails which are spams for everybody. Here is a nice solution for you. I’m using it for the last two years and I’m able to classify 40% of the mails which I receive as spams with 98% accuracy!! Isn’t it great. What you need is procmail installed on your system or you can download it from here..  http://www.procmail.org/

After installation create a file in your home directory.

FileName: $HOME/.procmailrc

Content of this file:

#Procmail Configuration file.
#Created by http://transcendental.wordpress.com

VERBOSE=off
MAILDIR=$HOME/mail      # Directory where your mails will be stored
PMDIR=$HOME/.procmail   # Directory where log files etc. will be created or where you’ll keep your general

configuration files.
LOGFILE=$PMDIR/log      # Name of log file
#DEFAULT=/var/spool/mail/<yourloginname>  # uncomment this line if your mails are delivered in /var/spool/mail/…
#INCLUDERC=/etc/mail/spamassassin/spamassassin-spamc.rc # uncomment this if you want

#:0 Hw
#* ^X-Spam-Status: Yes
#JunkMail

INCLUDERC=$PMDIR/general.rc

# end of .procmailrc
Now create a directory $HOMe/.procmail/
Create a file with name general.rc in .procmail directory.

#Content of general.rc file

:0
* ^From.*topcoder
../mbox  #move it to mbox directly. I dunno why I did this.

:0
* ^From.*wordsmith
{
        :0 c
        ../mbox

        :0
        Wordsmith  # I want it to go to two folders.
}

:0
* ^Subject.*LUG
lug    #move it to lug folder.
:0
* ^From.*(junkguy@gmail.com)
JunkMail

:0
* ^Subject.*(IP.*Conflict|Lost|Gazzag|test mail|missing|Filename|dance|has invited you to|Spam|Life|guitar)
JunkMail

:0
* !^From.*(gmail|orkut|microsoft|google|goodguy@yahoo.com)
JunkMail

#Note the last 3 lines. It says that all the mails which doesn’t come from gmail or orkut or microsoft or goolge or goodguy@yahoo.com will be classified as spam. This is a non-democratic way of classifying spam. But it works the best. Note (!) at the beginning of the second last line above this. BTW my configuration file is lot more complicated. For details man pages are always available.
#end of general.rc file

If you think that this really helped you then do write a scrap to me. I thought it would be really useful for everyone. It saved my precious time during the last two years. It’s really easy to modify the configuration file itself just add one keyword. Happy Mailing!!

Explore posts in the same categories: Mails, Procmail, Script, Spam Fighter, Technology

One Comment on “A simple spam fighter!!”

  1. John Quinion Says:

    It’s amazing. I never thought that spam filtering could be this simple. You rock!!. Not only I’m able to remove spams, I’m also able to treat my mails preferentially. Thanks a lot.


Comment: