How to Train SpamAssassin

From Email Marketing Wiki
Jump to: navigation, search

Here's a quick howto on training SpamAssassin to catch more SPAM email:

NOTE: You will need SSH access to your hosting server in order to run the commands below. If you don't have access, simply email

1. Collect some SPAM & HAM

  • Setup 2 new mail folders called 'HAM' and 'SPAM' (these must be IMAP folders not POP3 folders)
  • When mail arrives in your inbox, sort it into the two new folders - SPAM into 'SPAM' non-spam into 'HAM'
  • Do that for a few weeks or until you've got a good sample (20+) of emails in both folders.

2. Train SpamAssassin

  • SSH to your web server
  • Change your directory to the mail folder location containing the HAM & SPAM folders you created earlier. For example:
   cd /home/<myusername>/mail/<mydomain>/<mymailbox>/
  • Run the following commands on the HAM & SPAM files contained in this directory:
   sa-learn --siteconfigpath=/usr/share/spamassassin --showdots --mbox --spam SPAM
   sa-learn --siteconfigpath=/usr/share/spamassassin --showdots --mbox --ham HAM

That's it! That should take effect across all mailboxes under your account (not just the one you created the HAM & SPAM folders for).

This has worked well for me so far - your mileage may vary. You can run the command again at a later date to improve SPAM matching further, just make sure you have a fresh sample of SPAM & HAM in those folders first otherwise you won't see any improvement. You could also setup a Cron job to run this for you periodically.