This is a note more to my future self, but if it helps you out, I’d love to hear about it.
Train Spam
To train SpamAssassin to recognize spam, run this command via SSH:
sa-learn --spam --showdots path-to-junk folder
On my host that translates to
sa-learn --spam --showdots ~/mail/silverspider.com/alex/.Junk/cur
The cur
is important as it contains the actual messages within the Junk folder.
The “showdots” flag provides a progress indicator so that you know it’s working. It isn’t required.
Running this command in the terminal will look like this:
sa-learn --spam --showdots ~/mail/silverspider.com/alex/.Junk/cur
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
.........................................................................
...
Learned tokens from 514 message(s) (514 message(s) examined)
Train Ham
It’s just as important to tell SpamAssassin about non-spam messages, also known as ‘ham’. This ensures that it can recognize good messages and not inadvertently mark messages that you want to see as junk.
To train it using the contents of my inbox, I run this:
sa-learn --ham ~/mail/silverspider.com/alex/cur/
Running it for a subfolder is pretty straightforward, so long as you remember to include ‘cur’ at the end. If you have a space in a folder name, you need to escape it with a backslash. Here is the command to train it to recognize good messages in a folder named ‘Social Media’:
sa-learn --ham --showdots ~/mail/silverspider.com/alex/.Social\ Media/cur