Training SpamAssassin

SpamAssassin is one of the methods used on our servers to reduce the amount of spam received.  It automatically learns the type of messages you receive to improve filtering accuracy, however in some situations additional training may be beneficial. This method only works if you use IMAP and/or Webmail, as it relies on your ability to move emails to different folders.

The configuration process consists of three steps:

  1. Create a new folder named "spam" in your email client or webmail interface
  2. Create a cronjob using one of the following commands, we recommend running it once a day
  3. Ensure the "spam" folder is available in your email client

Training from one address from one domain:

sa-learn -p ~/.spamassassin/user_prefs --spam ~/mail/$domain.tld/$mailbox/.spam/{cur,new} >/dev/null 2>&1
sa-learn -p ~/.spamassassin/user_prefs --ham ~/mail/$domain.tld/$mailbox/{cur,new} >/dev/null 2>&1

 

Training all addresses from one domain:

sa-learn -p ~/.spamassassin/user_prefs --spam ~/mail/$domain.tld/*/.spam/{cur,new} >/dev/null 2>&1
sa-learn -p ~/.spamassassin/user_prefs --ham ~/mail/$domain.tld/*/{cur,new} >/dev/null 2>&1
Training all addresses from all domains:
sa-learn -p ~/.spamassassin/user_prefs --spam ~/mail/*/*/.spam/{cur,new} >/dev/null 2>&1
sa-learn -p ~/.spamassassin/user_prefs --ham ~/mail/*/*/{cur,new} >/dev/null 2>&1
Note: SpamAssassin will send messages it believes to be good (ham) to your inbox and bad messages to the spam folder on your account. If a message is incorrectly filtered, simply move it to the correct folder instead of deleting it. The next time SpamAssassin learning runs it will learn from the change to improve message delivery.

If you would prefer SpamAssassin learn from custom folders instead of the inbox and spam folder, you can update the command to use custom folders. The commands are case sensitive, so if you create a folder as Good then you must specify it as .Good in your command.

Training one address from one domain using custom folders (good & junk)

sa-learn -p ~/.spamassassin/user_prefs --spam ~/mail/$domain.tld/$mailbox/.junk/{cur,new} >/dev/null 2>&1
sa-learn -p ~/.spamassassin/user_prefs --ham ~/mail/$domain.tld/$mailbox/.good/{cur,new} >/dev/null 2>&1
  • 0 Users Found This Useful
Was this answer helpful?