You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Spamassassin Junkmail and Notjunkmail Learning in Mountain Lion

Like many others <https://discussions.apple.com/thread/4181320?start=0&tstart=0>, I wondered what happened to spamassassin and its Bayesian learning mailboxes "junkmail" and "notjunkmail" in OS X Server. Perhaps Apple had automated this process? There certainly isn't any documentation. I didn't think much of it until spam began falling into my server's INBOX, whereupon looking for a fix I discovered that spamassassin learning capabilities still work in Mountain Lion OS X Server, but they aren't automated in any way.


Here's how to train your server to detect the junk mail you receive, beyond the appropriate spam filter and greylist settings Server.app>Mail.


First, confirm that your serveradmin settings know about the spamassassin Bayesian learning mailboxes "junkmail" and "notjunkmail":


sudo serveradmin settings mail:imap | grep junk


mail:imap:junk_mail_userid = "junkmail"

mail:imap:not_junk_mail_userid = "notjunkmail"


Then use Server.app to add the network accounts "junkmail" and "notjunkmail" and edit access so that these accounts only have access to the Mail service. Add these accounts to Mail so that you (and other trusted users) have access to them.


Then dump all your junkmail from your server accounts and other cloud email accounts into the "junkmail" mailbox. Move any messages that aren't junk but marked as such into the mailbox "notjunkmail".


Finally,


sudo /Applications/Server.app/Contents/ServerRoot/usr/libexec/spamassassin/learn_jun k_mail.sh


This will train spamassassin based on the content of these mailboxes, and hopefully you will begin to see amavisd properly mark junkmail as "** JUNK MAIL **" in the subject line.

Mac mini Server (Mid 2010), OS X Mountain Lion (10.8.2), Lion Server, EyeTV HD, Turbo.264 HD

Posted on Nov 4, 2012 2:40 AM

Reply
34 replies

May 16, 2013 7:55 AM in response to bdemore

I believe the original settings parameter name is incorrect. Try:


sudo serveradmin settings mail | grep junk


and you will see the following:


mail:postfix:junk_mail_userid = "junkmail"

mail:postfix:not_junk_mail_userid = "notjunkmail"

mail:imap:junk_mail_userid = ""

mail:imap:not_junk_mail_userid = ""


If the "mail:postfix:..." settings are blank, set them to junkmail and notjunkmail.

Oct 21, 2013 10:51 PM in response to pterobyte

I am still completely stumped. I create two public folder in dovcot, junkmail and notjunkmail. I cannot figure out how to get spamtrainer to find the junkmail and notjunkmail imap folders when scanning/learining. it always looks for (and fails to find) GUID of the junkmail and notjunkmail users.


from what I am reading, the point of this is to not have to create these accounts, but to just create a couple public folders, or to create standard folders on all user accounts.. but this spamtrainer doesn't find them what the heck are the command line arguments to use the public folders junkmail and notjunkmail.

Oct 22, 2013 1:26 PM in response to Robb Allan

Did you try the options for top-level (-t) ?


I'm not 100% sure if the top level function works with a public folder namespace.

You can always read directly with something like


You'll want to do something like - this is untested in this specific form.. hopefully gets you on track.


SharedSpam="/Library/Server/Mail/Data/mail/SpamTrainer/.JunkMail"
SharedHam="/Library/Server/Mail/Data/mail/SpamTrainer/.NotJunkMail"

SpamDB="/Library/Server/Mail/Data/scanner/amavis/.spamassassin"
sa_PATH="/Applications/Server.app/Contents/ServerRoot/usr/bin/sa-learn"

$sa_PATH -u _amavisd --dbpath "$SpamDB" --no-sync --spam $SharedSpam/{cur,new}
$sa_PATH -u _amavisd --dbpath "$SpamDB" --no-sync --ham $SharedHam/{cur,new}


This simply tells sa-learn to read directly from your spam/ham directories.


You can add automatic purging and all sorts of other goodies....



To learn more:

man sa-learn

Nov 14, 2013 10:56 AM in response to Robb Allan

Hi,


I have been trying to figure this out. If I'm not mistaken, this thread is all about using the "junkmail" and "notjunkmail" accounts to learn spam. But it seems it's only if the users are using IMAP. Correct?


Our users are using POP3, so we can spam train by having them forward each spam message to the "junkmail" account, right? If so, can anybody tell me by the following if it is set up correctly, or do I need to do anything else?


I ran:

sudo serveradmin settings mail | grep junk


I got:

mail:postfix:spam_quarantine = "junk-quarantine@example.com"

mail:postfix:spam_notify_admin_email = "junk-admin@example.com"

mail:postfix:junk_mail_userid = "junkmail"

mail:postfix:not_junk_mail_userid = "notjunkmail"

mail:imap:junk_mail_userid = ""

mail:imap:not_junk_mail_userid = ""


Also, how do the quarantine and notify admin accounts work? Depending on your answer, if I want to set up accounts for them, how do I change those example.com defaults to the real accounts I set up?


This has been exhausting trying to find this out, thanks to Apple's lack of documentation.


Thanks very much!

Scott

Spamassassin Junkmail and Notjunkmail Learning in Mountain Lion

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.