<<<MacOS 10.12 Sierra Guides

Training the Spam Filter

When I was running Yosemite I used these commands to manage Spam, but in Sierra it is a little different.

Firstly spam trainer is not yet available for Sierra, although I only discovered that by downloading it and trying to install it.

Secondly it appears that Sierra does everything automatically. I don’t know why and can’t find any configuration pages or commands to set it up, but Spam Assassin is definatly managing Spam on my server.

This is how I did it, but again I do not know why or how this is working.

First and as before the basis of the system is to create two email accounts, the first for storing known junk mail (SPAM), the second for storing mail that was incorrectly marked as junk (HAM), by the bayesian filter.

On the server

Training Spam

Turn off all services except email for these accounts

Training Spam

Make it such that these two new users do not appear on the logon page

$ sudo dscl . create /Users/junkmail    IsHidden 1
$ sudo dscl . create /Users/notjunkmail IsHidden 1 
    

If you want to make them visible again, re-run the commands with a 0 instead of 1

Further information is available on the Apple WEB site

This time I did not create any custom Junk Mail filtering rules in my mail program.

Training Spam

I just accepted the defaults to move mail to the Junk folder.

I then added my junkmail and notjunkmail accounts to my mail program

Training Spam

And labelled them as SPAM and HAM.

Then when SPAM arrives, my mail program automatically moves it into the Junk folder. I then check that it is actually SPAM and manually move the mail to the In Box of my junkmail user (SPAM).

The other part of this, and the bit I can’t find any settings for is Spam Assassin.

Reading the manual for Spam Assassin it appears that it is possible to teach Spam Assassin to distinguish SPAM from HAM, by pointing it to your local Junk folder so I ran the following commands

Mike$ sa-learn --no-sync --spam --mbox Library/Mail/V4/2F6D2129-FE05-49F2-8C15-9697FEFA63C3/Junk
Learned tokens from 0 message(s) (0 message(s) examined)
    

But as you can see this did nothing, I also tried this with Sudo and got the same result.

I then tried to dump the contents of the database to see what info was stored

Mike$ sudo sa-learn --dump magic
ERROR: Bayes dump returned an error, please re-run with -D for more information
    

The manual states that this is the result you get when no data has been collected

So I ran the sync command to collect all of the mail data

Mike$ sudo sa-learn --sync
bayes: synced databases from journal in 0 seconds: 876 unique entries (1170 total entries)
    

Now when I check the contents of the database I get the following

Mike$ sudo sa-learn --dump magic
0.000          0          3          0  non-token data: bayes db version
0.000          0        331          0  non-token data: nspam
0.000          0       2852          0  non-token data: nham
0.000          0     137600          0  non-token data: ntokens
0.000          0 1475854471          0  non-token data: oldest atime
0.000          0 1480671745          0  non-token data: newest atime
0.000          0 1480672094          0  non-token data: last journal sync atime
0.000          0 1480521038          0  non-token data: last expiry atime
0.000          0    2764800          0  non-token data: last expire atime delta
0.000          0     119145          0  non-token data: last expire reduction count
    

And more importantly every moring the in box for my junkmail and notjunkmail users has been emptied and the nspam and nham counts shown by the previous command is going up.

My conclusion is that somehow my spam trainer is working, but as I said earlier I can not find any commands that are causing this, or that can be set to alter this behaviour.

I would expect there to be someting in the mail settings in the Server settings

Training Spam

But the only option in there is the Filtering Settings

Training Spam

And there is nothing in there that I can alter.