Setting up Spam Assassin:

Important Notes:

In this tutorial we assume:

your username is jdoe12
your server name is vivid.phpwebhosting.com

You'll need to replace all instances of jdoe12 with your real username and all instances of vivid.phpwebhosting.com with your servername.

We use emacs as the editor in our examples but you can use any editor you want.

Description:

First, a frequently asked question: Why no automatic, site-wide spam assassin?

We are working on automatic site-wide installs. However the usual install for a webhost involves setting all users to use the same
strength and level of spam-blocking. This is not acceptable for many of our clients.

Our business clients usually cannot afford to block anything. Business's cannot afford missing a customer communication. On the other hand our more technical clients running their personal mail usually want to be able to totally tweak and configure the spam rules file. The procedure below is currently the only way that allows total configuration of spam assassin.

This tutorial involves four parts. You must follow every step of every part for this to work. It may be a bit complicated if you are new to this sort of thing. However you will end up with a 100% configurable spamassassin install that you can set to filter in any way you please. It will be just like a totally private root install but just for your account.

Overview:

Part one just makes sure you have working shell mail. It is very easy and just done to avoid further problems. Do not skip this part. You need to confirm you have regular working shell mail before you start customizing the configuration. It's no fun to spend hours trying to debug a problem just to find out that your basic mail setup never worked in the first place!

Part two downloads and installs the spamassassin software. Again, very simple. Just follow the instructions and you'll have no problems!

Part three sets up your shell mail to start filtering through spam assassin.

Part four shows you how to forward addresses@your_domain.com to spam assassin.

Let's get started!

Part One:

Verifying you have working shell mail.

1. Login to ssh

2. Type:

pine

3. Go to the main menu (press the m key) - you should be here by default but press it just in case.

3. Go to setup (press the s key)

4. Go to configure (press the c key)

5. Verify that inbox-path is set to your directory and Mailbox file:

inbox-path               = /home/jdoe12/Mailbox

if not, go to that entry and change it

6. Exit setup (press e) and save changes (if you made any it will prompt you to save, press y)

7. Exit out of pine (press q)

6. remove any existing .qmail-default file :

Note - throughout this tutorial we assume that you have not already set up any .qmail files or .procmail files. If you have, you'll need to remove/adjust those to work with the tutorial. Be careful when doing this. Removing those files will break any other mail handling you setup
prior to this

rm ~/.qmail-default

6. Create an empty .qmail-default file. type:

touch ~/.qmail-default

(notice the dot in front of qmail - the full file is .qmail-default NOT qmail.default)

7. Send some mail to yourself at the shell:

mail jdoe12@vivid.phpwebhosting.com

Replace this with your actual shell mail user and server! Also, do NOT try to send to a user@your_domain.com yet. This step
is just setting up basic shell mail. We'll set up mail to your domain at the end of the tutorial. Get this part working first!

8. Open up pine, go to your inbox and check to make sure the mail arrived

9. If you got the mail, move to part two.

If you did not get the mail, do NOT proceed. Retrace the above steps, do not continue until you have your basic shell mail working. If you continue you'll just cause yourself headaches. Make sure the above works. It should work without any problems at all. This section of the tutorial is here
just to make 100% sure that your shell mail works. There is no point in continuing if your basic shell mail is not working.

Part Two:

Install spam-assassin

0. Just to be safe, we'll remove any copies of old install attempts. Be carefull when running the commands below - they will delete any files and
directories named Mail-SpamAssasin* - we do this step just in case you have any failed download attempts. If in doubt, do not run this step. It really is just an extra paranoid step used to prevent any later problems.

rm -fiR ~/Mail-SpamAssassin*

1. Download spam assassin:

Note: The basic goal of this step is to find the location of the latest SpamAssassin install file. The steps below may change in
the future (for example if the spamassassin.org website changes their layout, etc.). The steps listed below are just an example.

go to http://www.spamassassin.org/ in your browser
click download
find the version you want, tar.gz format
copy down the address for the link (in many browsers you can right-click the link and do "copy url or copy shortcut" to put the url into your cut-and-paste buffer) as of this writing it is:

http://www.spamassassin.org/released/Mail-SpamAssassin-2.60.tar.gz

Now go to your shell and type use wget to grab the file:

cd ~/
wget http://www.spamassassin.org/released/Mail-SpamAssassin-2.60.tar.gz

2. Unpack it:

cd
tar xzpf ~/Mail-SpamAssassin-2.60.tar.gz

Note - if the version you downloaded is not version 2.60 - you'll need to update the above command to properly reference the file you downloaded

3. cd to the dir

cd ~/Mail-SpamAssassin-2.60

Note - if the version you downloaded is not version 2.60 - you'll need to update the above command to properly reference the file you downloaded

4. Prepare the files for building:

perl Makefile.PL PREFIX=~/sauser SYSCONFDIR=~/saetc

The configuration might ask you will ask you a questions - just press enter for each. This will accept the default answer.

5. Build the SpamAssassin files :

type:

make

after make completes, type:

make install

Note: if you get errors about not being able to build files, login to your control panel and enter a quick request for compiler access

6. Type cd to return to your home dir

cd


Part Three: Have spamassasin process your incoming mail

1. Create a new file called .procmailrc

emacs ~/.procmailrc

2. Inside the file put the lines:

MAIL=/home/jdoe12/Mailbox

# this runs spamassassin
:0fw: spamassassin.lock
| /home/jdoe12/sauser/bin/spamassassin

# this puts all mail with the X-Spam-Status: Yes header into a mail folder called caughtspam
# to use this, remove the # characters from the next three lines
#:0:
#* ^X-Spam-Status: Yes
#/home/jdoe12/caughtspam

# this puts all other mail into the box /home/jdoe12/Mailbox
# Always include these lines or you won't get any mail!
:0
*
/home/jdoe12/Mailbox

For the best results, copy and paste the above lines into the file. If you type them manually you may make a mistake.
When finished, edit the file to replace all instances of jdoe12 with your actual username.

Make 100% sure that you have replaced all instances of jdoe12 with your actual username! Your mail will NOT work otherwise!

save the file and exit

3. Edit your ~/.qmail file, put in the following line:

|IFS=' ' && exec /usr/bin/procmail -f- || exit 75

Make sure there are no other lines in your .qmail file. Save and exit.

3.5 copy .qmail to .qmail-default

cp ~/.qmail ~/.qmail-default

3. Try to send yourself another test mail

mail jdoe12@vivid.phpwebhosting.com

(replace this with your actual shell mail user and server!)

4. Make sure you got the message. If not, find out why before proceeding

5. Send yourself some fake spam:

put the following in a message:

XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

it is a special line that will always trigger the spam filter

The message should show up in your box but with some SpamAssassin text added to it. Make
sure you get the message with the spam warning in the body. If not, go back and find out why.

Next, we'll make spam assassin alter the subject line of the message to indicate the mail is spam:

Edit the file:

~/.spamassassin/user_prefs

Add these lines to it:

# Whether to change the subject of suspected spam
rewrite_subject         1

# Text to prepend to subject if rewrite_subject is used
subject_tag             [ SPAM ]

Now resend your spam message above (any message with the text

XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

in it)

It should show up in your mail box with the subject line pre-pended with [ SPAM ] . You can now use your
mail program to sort, delete, etc. with that as the subject line. You can edit the ~/.spamassassin/user_prefs
file to change the subject line to whatever you want.

Part four : forward your domain mail to your shell mail

1. Login to your email admin interface:

http://vivid.phpwebhosting.com/cgi-bin/qmailadmin

(Note: change vivid.phpwebhosting.com to the name of your actual phpwebhosting server!)

2. Set up an alias to forward any usernames at your domain to your shell mail. For example, to forward the name jdoe@your_domain.com do
the following:

First delete any POP3's for the user jdoe
Next, add an alias from jdoe to your_username@your_server.phpwebhosting.com - in our example this would be jdoe12@vivid.phpwebhosting.com

3. If you would like to forward all mail at your domain, use the link at the top of the mail admin page and set the forward to your_username@your_server.phpwebhosting.com - again, in our example this would be jdoe12@vivid.phpwebhosting.com

Note - the catch-all only forwards un-defined mail accounts. If you already have an alias or a pop3 defined mail to that address will NOT be
forwarded. You would need to delete it first.

The mail system works like this:

1. mail comes in for jdoe@your_domain.com
2. system checks for a jdoe alias and tries to deliver it. If it finds one, it delivers the mail and stops
3. system checks for a jdoe POP3 and tries to deliver it. If it finds one, it delivers the mail and stops
4. system checks for a catch-all address, if it finds one it puts the mail for jdoe into the catch-all and stops
5. if not matching user and no catch-all are found, the system bounces the mail back as undeliverable


Further Steps:

7. Configure spam assassin

Since your install is totally private you can further edit the

~/saetc/mail/spamassassin/local.cf

to your liking. You can also edit your

~/.spamassassin/user_prefs file

You may also want to edit your

~/.procmailrc file and uncomment the lines

# this puts all mail with the X-Spam-Status: Yes header into a mail folder called caughtspam
# to use this, remove the # characters from the next three lines
#:0:
#* ^X-Spam-Status: Yes
#/home/jdoe12/caughtspam

(to uncomment a line, just remove the # sign at the start of the line)

This would put all your spam into a special folder.

As always, be careful when filtering spam. It is very possible to filter mail that is NOT spam. If you seem to be missing mail, make
sure you check any folders you set up as spam folders.


Removal:

To remove SpamAssassin, do the following:

rm ~/.qmail-default
rm ~/.qmail

touch ~/.qmail
cp ~/.qmail ~/.qmail-default

This will turn the spam filtering off. You can also delete the directories with the spam assassin files

~/.spamassassin
~/sauser
~/saetc
Mail-SpamAssassin-2.60


[ last updated: Nov. 11, 2003 - 1:34 am ]

www.phpwebhosting.com