Filtering Spam with spamassassin


Copyright 2002, 2003 Andy Barclay
OpenContent License (OPL)
You'll need perl installed on your system for this to work.
You'll also need BerkeleyDB installed
There is a description of how to install BerkeleyDB buried in
this document.

I've added this because a friend asked me to do it. Its a little
terse (not as good as my other howtos but it should work)

Seeing as you are reading this, its a good time for me to
plead with all the e-mail admins out there.

PLEASE, PLEASE, PLEASE - Don't bounce mail simply because
people are on the SPEWS list. Spamassassin's default
rule set adds to the total score for the email if any
one of the MTAs is on the SPEWS list, so there is
no need to do it.
Thanks.

Ok, now to install and use spamassassin.

Note: if you don't have perl or a C compiler or whatever,
and you are running Solaris 8+, you can use my packages.
They are available here
See the Appendix A at the bottom of this sheet for 
information on how I built the package.

You will also need BerkeleyDB installed in /usr/local/BerkeleyDB

Step #1) Use perl to fetch the needed perl modules

sudo perl -MCPAN -e shell

install Bundle::CPAN
install Term::ReadKey  ------ this failed.
install Net::DNS
force install Net::Ping --- tried without force, and it failed
install Time::HiRes
install Digest::SHA1
install Mail::Internet
install HTML::Parser
install DB_File

Step #2) Get the razor sdk and agents
download razor sdk and agents from http://razor.sourceforge.net
	extract agents and sdk
	cd sdkdir
	sudo perl Makefile.PL
	make
	make test
	sudo make install

	cd agentsdir
..... note  you should download the spamassassin source at this point
and then apply the included patch.....
	/usr/local/bin/patch -p0 -d lib/Razor2 
Appendix A - How I built the packages

If you are going to install the packages, you will need 3:
UPperl - perl
UPbdb - Berkeley DB
UPspam - spamassassin

The machine that I am installing spamassassin on has a core install
of Solaris 9 with no make and no C compiler.
The CPAN method of installing perl will not work.

So, I used another Solaris 9 machine with make and a C compiler, then
did the install, then created a package.

On the 3rd-party server, I:
-removed SUWNpl
-installed gcc 3.2.1
-installed berkeley DB

touch /tmp/perl

-downloaded perl 5.8.1
	sh Configure.sh
	make
	make test
	make install
-download HTML-Parser
	perl Makefile.PL
	make
	make install
-download DB_File
	-had to change paths in config.in to refer to
		/usr/local/BerkeleyDB.4.0 rather than /usr/local/BerkeleyDB
	perl Makefile.PL
	make
	make install
-download Digest-SHA1
	perl Makefile.PL
	make
	make install
-download Digest-HMAC
	perl Makefile.PL
	make
	make install
-download Net-DNS
	CC=gcc perl Makefile.PL
	make
	make install

Now, take all the files that were installed and make them
part of the UPperl package.
cd /usr/local
find . -newer /tmp/perl >/tmp/perl.files

touch /tmp/spam
-download razor-agents-sdk
	perl Makefile.PL
	make
	make test
	make install
-download razor-agents
	perl Makefile.PL
	hmmm, got an error here about Digest::SHA1 not found
	but I know I installed it....
	make
	damn, now its complaining about the version of Digest::SHA1 not
	matching. Went back and re-installed Digest::SHA1 2.06, then removed
	the old version of Digest::SHA1 that
	was bundled with razor-agents-sdk, then ran make clean,
	and re-installed it.
	make test
	make install
	razor-client
	razor-admin -create
-Mail-SpamAssassin-2.70
	perl Makefile.PL
		used info@unixpeople.com for contact address
		told it to run network tests
	make
	make install

Now, take all the files that were installed and make them
part of the UPspam package.
cd /usr/local
find . -newer /tmp/spam >/tmp/spam.files

make UPspam dependent on UPperl and UPbdb

Appendix B - Training Spamassassin

Spamassassin has the ability to use baysian filters to help it
detect spam. If you want really accurate spam filtering, then you
need to use this *AND* you need to do it right.

Here is the right way to do it.

After spamassassin is operational, if any spam makes it into your
inbox, DO NOT DELETE IT. Instead, manually move it to your spam folder,
then periodically run the following command (you can do this through
cron or whatever).

$ sa-learn --spam --mbox ~/Mail/spam

After you run this command you can delete the spam in your spam folder

Conversely, if any non spam (ham) ends up in your spam folder, move it
to a folder (like your inbox, or a folder named nonspam) and then
run this command periodically:

$ sa-learn --ham --mbox ~/Mail/NOTspam

Note: if you like to see the progress of the program, you can add
the --showdots option.