Filtering Spam

If you are constantly bombarded with SPAM you're not alone and you may want to consider filtering your mail. This document will give you step by step instructions on how to filter SPAM. We don't guarantee that it will catch all SPAM, and we don't guarantee that a real message will never be mistaken for SPAM, but for the most part filtering does more good than bad.


Step 1: Is your system running qmail or sendmail

The first thing you need to do is see if your system is running qmail or sendmail. Your system should be running one or the other but not both. Try the following commands below, the output will not match exactly but should look similar.

Test for sendmail
unix% ps -aef |grep sendmail | grep -v grep
  root   209     1  0   Jul 18 ?        0:00 /usr/lib/sendmail -q1h
Your system is running sendmail
unix% ps -aef |grep sendmail | grep -v grep
unix%
Your system is not running sendmail
Test for qmail
unix% ps -aef |grep qmail | grep -v grep
  qmaild  8583   190  1 15:12:35 ?        0:00 /var/qmail/bin/qmail-smtpd
  qmailq  3229  3224  0   Aug 04 pts/58   0:36 qmail-clean
  qmailr  3228  3224  0   Aug 04 pts/58   0:09 qmail-rspawn
  qmails  3224     1  0   Aug 04 pts/58   2:11 qmail-send
  qmaill  3226  3224  0   Aug 04 pts/58   0:55 splogger qmail
Your system is running qmail
unix% ps -aef |grep qmail | grep -v grep
unix%
Your system is not running qmail


Step 2: Create your forwarding file

The next thing you need to do is create a forwarding file. If your system is running sendmail the name of your forwarding file will be ~/.forward. If your system is running qmail the name of your forwarding file will be ~/.qmail.

Here is what you want to put in your forwarding file:

"|IFS=' '&&exec /usr/local/bin/procmail -f-||exit 75 #YOUR_USERNAME"
where YOUR_USERNAME is your username (e.g. ledzian) rather than the text YOUR_USERNAME. Note that all of the quotes and the # belong there though.

If you already have something in your forwarding file, end the existing entry with a comma, and add the line above.


Step 3: Create your ~/.procmailrc

The last step is the same whether your system is running qmail or sendmail. You need to create a file called ~/.procmailrc and fill it with stuff. The stuff you fill it with are addresses of sites that spam. This list is constantly changing and the most current version can be found at: Procmail Spam Filter

For an excellent discussion of how to use Procmail, see this page.

For a good get-this-guy-off-my-back, see Don Watrous' page on the matter.


Some things you need to know

When your done setting stuff up, test it out. Send mail to yourself and make sure you get it.

Everything that the spam filter thinks is spam mail will be put in a file called junk.mail. You may want to check this junk mail now and then to make sure that no important messages were mistaken for spam. If you don't know how to open an arbitrary file will your mail reader you can always use more.

unix% more ~/junk.mail

If you have any questions you can mail help