How to fight spam using spamassassin, dnsbl, and procmail

Picture of How to fight spam using spamassassin, dnsbl,  and procmail
I run my own mail server, and I check my email most of the time using pine. Over the years I had set up spam filters in pine to weed out spam. But I have also been known to use my blackberry to check email using squirrelmail. Well my pine filters did not work on squirrelmail. Plus more spam had been coming through lately.

This instructable will show you how to set up spamassassin on Fedora using procmail to move messages marked as spam to a spam folder automatically.

Remove these adsRemove these ads by Signing Up

Step 1: Install prerequisites

Picture of Install prerequisites
You'll want to install your prerequisites:

joe@fletcher ~$ sudo yum install sendmail-cf sendmail procmail spamassassin spammass-milter

Step 2: Sendmail Configuration

Picture of Sendmail Configuration
You want to check that sendmail is using the DNS Blacklist.

Edit sendmail.mc and add the lines below

joe@fletcher ~$ vi /etc/mail/sendmail.mc
FEATURE(`dnsbl', `bl.spamcop.net', `"Spam blocked see: http://spamcop.net/bl.shtml?"$&{client_addr}')dnl
FEATURE(`dnsbl', `cbl.abuseat.org', `"Spam blocked see: http://cbl.abuseat.org/lookup.cgi?ip="$&{client_addr}')dnl
FEATURE(`dnsbl', `sbl.spamhaus.org', `"Spam blocked see: http://spamhaus.org/query/bl?ip="$&{client_addr}')dnl
FEATURE(`dnsbl', `list.dsbl.org', `"Spam blocked see: http://dsbl.org/listing?"$&{client_addr}')dnl

While you have that open, add procmail as the default mailer:

Step 3: Sendmail restart

Picture of sendmail restart
After you have made your changes to sendmails mc file you should restart the sendmail service to rebuild the config file (sendmail.cf)

joe@fletcher ~$ sudo service sendmail restart

Step 4: Set up procmail logging

Picture of Set up procmail logging
joe@fletcher ~$ sudo vi /etc/procmailrc
#Uncomment below for troubleshooting

You can check procmail now by tailing the log file under /var/log

joe@fletcher ~$ tail /var/log/procmail

Step 5: Local procmail config

Picture of local procmail config
Create a .procmailrc in your home directory
joe@fletcher ~$ vi .~/procmailrc
  • X-Spam-Status: Yes
Siebe6 years ago
i like ham not really
mchenson6 years ago
You should also join Spamcop - as you know the Spammer's address is invariably bogus, and the Subject line subject change with the hour. The only real way to stop Spammers is to go after the Open Relays and Ports they use to send their Spam from. And of course make sure your SMTP-relay is as secure as possible!