SpamAssassin under DirectAdmin


New Member
I've just installed and configured SpamAssassin under DirectAdmin, and I wanted to share a bit about the process.

First of all, the instructions for installing SpamAssassin are available on the DirectAdmin site:

I modified the setup script to select the current version of SpamAssassin (3.1.7) rather than what was documented in the script (3.1.4). The script did work fine using the DirectAdmin site to pick up the necessary perl modules, so if you make this modification only pick up the SpamAssassin tarball from its site. As a note, the wget I added to (replacing getFile $FILE) was:

The script does all the compiling and installation for you. No separate init script is created to start the SpamAssassin daemon spamd; it is instead started from the exim init script.

Once installed, you must go into your DirectAdmin control panel and enable SpamAssassin for each domain separately. Once you click on "enable", a form will come up that you must set a few options on and click "save'. Once saved, you'll find a directory called ".spamassassin" will be created in the home directory of the DirectAdmin account owner for that domain, and a minimal user_prefs file will be created.

If you choose to have your spam put into a "spam" folder as I did, you'll find there will be a subdirectory under that directory called "user_spam" with filenames such as "" indicating one file per user for your domain. There appears to be only one way to access the spam folder, and that is via webmail. Perhaps there is a way to pop that email off into your client, but in my case thus far I've found it's 100% pure spam so my only concern is deleting it once in awhile. This is a manual operation which can be done by either having each user log into webmail and clean it out, or you can log into your DirectAdmin account and go to the Email area and show users, and from there click on the checkboxes for all users you want to empty out their spambox then select the "spambox" radio button and click "Empty". Be careful here; you can also click the "Delete" button which will instead delete the selected accounts, and there's no undo.

I do occasionally peek at the subject lines of the email using a one-liner on the command line (via ssh):

% grep "^Subj" $HOME/.spamassassin/user_spam/ | less
This lets me page through the subjects and quickly figure out if there might be any false positives. None so far, which mirrors my experience on my home server where SpamAssassin has been in use for three years.

You can also choose to receive the email with the subject line modified to include a "## SPAM ##" at the front, or pass it through with just the spam headers added, or just have it deleted immediately. A modern email client like Thunderbird can filter the spam into a separate spam folder for you if you choose to have the spam included in your downloads.

You can add some additional rulesets that make SpamAssassin catch more spam, at the possible expense of some false positives. The Rules Emporium has a number of useful rulesets:

Read the notes for each ruleset file carefully; there are some that have a big impact upon resource usage and others that are known to have false positives.

If you wish to use Bayesian filtering, you can hit the ground running by training SpamAssassin with several hundred known spam and known ham emails and putting the data into your .spamassassin directory. This is the most effective way to make the Bayesian filter work right off the bat. I found instructions on how to transfer my bayes database from my home server to the VPS (using "sa-learn --backup" and "sa-learn --restore"); note that just copying over the bayes_seen and bayes_toks files directly didn't work.

You can initialize your bayes database using a public corpus of spam and ham which is better than not having it but is probably not quite as good as using your own spam and ham. If you have your own, use it, so long as it's a few hundered messages each of spam and ham.

Lastly, I don't care for negative scoring when using bayes. What this means is that the total score of an email can be reduced by a few points if the bayes engine gets few or no hits against its database. So I modifiy the rules that govern this by adding these lines to the user_prefs file:

score BAYES_00 0.0001 0.0001 0.0001 0.0001
score BAYES_05 0.0001 0.0001 0.0001 0.0001
score BAYES_20 0.0001 0.0001 0.0001 0.0001
score BAYES_40 0.0001 0.0001 0.0001 0.0001

The scores in the last two columns by default are negative; I essentially zero them out.

That's it; enjoy!

I attempted to get this installed last night, and when I got to the step where I need to start the spamd, I get the following error:

-bash: /usr/bin/spamd: No such file or directory

Something must have gone wrong. Thoughts?

It seemed that the script ran just fine and prompted me all the way through. I didn't see any errors.
Something must have gone wrong. Thoughts?

It seemed that the script ran just fine and prompted me all the way through. I didn't see any errors.
Look in /usr/local/directadmin/scripts/packages/Mail-SpamAssassin-3.1.7 and see if things got compiled. You should see spamd/spamd there, as well as spamc/spamc. If they are present, try running 'make install'; if they're not there, try running just 'make' again and in either case watch for error messages.
I checked it out, and nothing was installed properly. I went back to the and realized that I needed to change VERSION=3.1.4 to 3.1.7

Seems the install worked now.