How to make SpamAssassin learn which emails are HAM and SPAM?


Use sa-learn utility which enables to teach SPAM and HAM to SpamAssassin. First though you must learn which user is running the amavisd process.

# ps aux | grep amavis
vscan     4589  0.0  2.2  53536 45096 ?        Ss   Jun24   0:07 amavisd (master)

This means user “vscan” is the owner of the “amavisd” process. Therefore we must insert into bayes database of user “vscan” information about SPAM and HAM respectively. Therefore login (or du “su”) as user vscan and run the following command:

$ sa-learn --spam --showdots --dbpath $DBPATH $spamfolder

–showdots will show dots as SA SPAM learning process is in progress (it might take long if you have many spam files, so it is a useful option), –dbpath $DBPATH tells SA path to the spam database file. $spamfolder is the folder from which all mails files will be processed and considered to be SPAM. Similarly you can teach SA also MAH:

$ sa-learn --ham --showdots --dbpath $DBPATH $spamfolder


  1. A very good tutorial how to set up virtual users with Postfix. Very clear and nicely explained.
  2. postfix_virtual_users
Teaching SpamAssassin HAM and SPAM

Leave a Reply

Your email address will not be published. Required fields are marked *