|
|
How to set up Spam Assassin
SpamAssassin is great. I get over 100 spams a day (old, old email addresses) and have only been partially successful in filtering them off on my own. It catches them very well.....when it's set up correctly.
Unfortunately I didn't find the instructions on the Spam Assassin web site useful -- nor any of the links they pointed to -- and it took me a lot of figuring to get it to work.
If you have root on the system, and are installing it for everyone, it
may be very easy. But I don't.
There may be better ways, but the following is what worked for me...:
- Download Spam Assassin
- Compile it
If you're not the sysadmin, you'll want it in your home directory. Do this by running the "perl Makefile.PL" like:
perl Makefile.PL LIB=/home/binde/lib PREFIX=/home/binde
Then do a normal 'make'
- make install
...doesn't actually work right. Go ahead and run a 'make install', but it will error out because it will try to copy files in a system location.
When the 'make install' is done, run 'make -n install' to see what additional commands its running and replicate those on your own.
e.g., with version 1.21, I had to do:
mkdir -p /home/binde/share/spamassassin
cp rules/user_prefs.template /home/binde/share/spamassassin/user_prefs.template
for file in 10_misc.cf 20_body_tests.cf 20_head_tests.cf 20_uri_tests.cf 25_body_tests_es.cf 25_body_tests_pl.cf 25_head_tests_es.cf 25_head_tests_pl.cf 30_text_de.cf 30_text_es.cf 30_text_fr.cf 30_text_pl.cf 40_spam_phrases.cf 50_scores.cf 60_whitelist.cf triplets.txt languages ; do cp rules/$file /usr/home/binde/share/spamassassin/$file; done
- Modify Spam Assassin
Rather than dealing with setting my perl environment variables to find the new path, I simply added this after the "!#/usr/bin/perl" line:
use lib '/usr/home/binde/lib';
- Test Spam Assassin
Really. Follow the directions in the Makefile.
You will need to also give it "-c /home/binde/share/spamassassin" -- at least I had to.
- Get Razor and install it (if you want to use Razor)
...but not version 2! SpamAssassin doesn't work with version 2 yet. Unfortunately all the docs on Razor's website are for version 2.
Go here to get a copy of version 1.
You also need the LIB and PREFIX lines on Razor. But here, the 'make install' works just fine.
- Test Spam Assassin
Really. Follow the directions in the Makefile. again.
To see if it's finding Razor, run the tests with "-D" and grep the output on STDERR for references to "Razor" -- make sure it says that it finds Razor and can contact it.
- Set up Spam Assassin in procmail
Finally, I added this at the top of my .procmailrc:
:0fw
| /usr/home/binde/bin/spamassassin -P -c /usr/home/binde/share/spamassassin/rules
:0e
EXITCODE=$?
I want to filter into a "junk" folder, so also have:
:0:
* ^X-Spam-Flag: YES
junk
:0:
* ^X-Spam-Status: Yes
junk
And added this to my .muttrc so I could report un-caught spam to Razor:
macro index X "| /usr/bin/spamassassin -r" "report message to Vipul's Razor"
- Test the full Spam Assassin setup
- Re-run the test with -D, as described above, to make sure it's finding Razor
(unfortunately this cannot be done except from the command line, since it writes to STDERR; I'd like to modify it to log debug messages to a file but haven't gotten around to it.)
- Send yourself an email message and look at the full headers
- If you don't see an "X-Spam-Status" header, SpamAssassin isn't being run at all.
- If you do see it, but the headers look like:
X-Spam-Status: No, hits=0.0 required=5.0
tests=none
version=2.31
(i.e. the hits are 0.0) then it's being run but can't find its rules files -- check that you're using "-c", that the directory exists, and that it contains the same thing the "rules/" directory does in the SpamAssassin distribution.
- If you do see it, and the headers look something like:
X-Spam-Status: No, hits=-2.1 required=5.0
tests=FROM_AND_TO_SAME
version=2.31
(i.e. the hits aren't 0.0) then it's being run and works.
Unfortunately, as noted above, I don't know a way to check that Razor is being hit when you're running it from procmail.
- Wait for spam
When some shows up, open it and check out the headers. Check that the subject line re-writing is being done properly, etc.
|
|