Previous 1 2 3 Next 34 Replies Latest reply: Nov 14, 2013 10:56 AM by scottl31
essandess Level 1 (15 points)

Like many others <>, 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>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 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".




sudo /Applications/


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
  • Kostas B Level 1 (90 points)

    This is great info, thanks for sharing.


    2 questions:


    1. How do you set this accounts as "public folders"? Or you just instruct users to add these accounts in their Mail client?

    2. Does "learning" and removing false spam marking really works?


    Best regards



  • essandess Level 1 (15 points)

    These are IMAP account names, not public folders (even though they do exist as folders within the guts of /Library/Server/Mail/Data, you have to let IMAP worry about that stuff). You can either:


    1. Instruct users to Mail>Message>Send Again [Cmmand-Shift-D], then send the junk/notjunk to these respective accounts.

    2. Distribute the password(s) for the junkmail and notjunkmail accounts, allowing users to add them and simply drag and drop directly, or add a rule do redirect junk.


    Yes, Bayes Rule really works. I see "*** JUNK MAIL ***" marked email notifications as I type this from the same spammer that was making it through unmarked before (a pretty good feat these days!). This junk is automatically directed into my personal Junk Mail folder. I'll added them to junkmail later, or write a rule to do this automatically.


    Spamassassin has script to unlearn mistakes, though I've never used it. Also, I believe that Snow Leopard Server automatically scraped the contents of the junkmail and notjunkmail accounts every week, making the last script above unnecessary—we have not been told whether this feature exists in Mountain Lion, thou it wouldn't be hard ton search for any daemon that called the script .

  • Jeff Hargrove Level 2 (235 points)



    I discovered this post and tried the command you suggested for training junkmail, however I got an error message instead:


    server:~ admin$ sudo /Applications/


    grep: /Applications/ No such file or directory

    Can't determine mail store path from /Applications/


    How can I fix this?





  • essandess Level 1 (15 points)

    Curious. I can just show you my server's setup, and perhaps if you replicate the problem will go away.


    ls -l /Applications/


    lrwxr-xr-x  1 root  wheel  54 Oct 28 22:41 /Applications/ -> /Library/Server/Mail/Config/dovecot/partition_map.conf


    ls -l /Library/Server/Mail/Config/dovecot/partition_map.conf


    -rw-r--r--  1 root  wheel  39 Sep 22 01:54 /Library/Server/Mail/Config/dovecot/partition_map.conf


    cat /Library/Server/Mail/Config/dovecot/partition_map.conf



  • essandess Level 1 (15 points)

    P.S. You fixed my cut-and-paste typo, right? The correct command is:


    sudo /Applications/

  • essandess Level 1 (15 points)

    Wow. This editor keeps adding that extra space in the word Never mind.

  • Jeff Hargrove Level 2 (235 points)

    Yes, I did fix the typo.


    However following your commands, I still get an absent partition_map.conf file:


    server:~ admin$ ls -l /Applications/

    ls: /Applications/ No such file or directory

    server:~ admin$ ls -l /Library/Server/Mail/Config/dovecot/partition_map.conf

    -rw-r--r--  1 root  admin  39  7 nov 08:22 /Library/Server/Mail/Config/dovecot/partition_map.conf

    server:~ admin$ cat /Library/Server/Mail/Config/dovecot/partition_map.conf


    server:~ admin$


    Is it the same file in both locations? Can I copy it into /Applications/ ?

  • essandess Level 1 (15 points)

    You have to issue these commands to replicate what I see on my server:


    sudo ln -s /Library/Server/Mail/Config/dovecot/partition_map.conf /Applications/

    sudo chown root:wheel /Applications/

    sudo chmod 755 /Applications/


    Jobs knows why that symbolic link didn't come with your

  • Jeff Hargrove Level 2 (235 points)

    haha, Yes I agree. With each clean installation, nothing is the same!


    Well it seems to have worked! Does this look right to you?


    server:~ admin$ sudo /Applications/

    Learning what is junk mail

    --- sudo -u _amavisd /Applications/ --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/cur/1352283,S=50277,W=50949:2,Sa

    --- sudo -u _amavisd /Applications/ --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352293,S=49035,W=50239

    --- sudo -u _amavisd /Applications/ --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352308,S=6250,W=6422

    --- sudo -u _amavisd /Applications/ --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352371,S=1362,W=1391

    --- sudo -u _amavisd /Applications/ --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352495,S=16231,W=16452

    --- sudo -u _amavisd /Applications/ --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352495,S=19331,W=19592

    --- sudo -u _amavisd /Applications/ --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352495,S=13378,W=13563

    --- sudo -u _amavisd /Applications/ --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352495,S=13001,W=13180

    Learning what is not junk mail

    find: /Library/Server/Mail/Data/mail/5A73D415-CF7B-4C2F-AAEF-FF2F8536493E/cur: No such file or directory

    find: /Library/Server/Mail/Data/mail/5A73D415-CF7B-4C2F-AAEF-FF2F8536493E/new: No such file or directory


    I don't like the last two lines, though!

  • essandess Level 1 (15 points)

    That's it! All those crazy file names are imap email files in your junkmail account. The last two lines are just because you've never stuck anything into the notjunkmail account, and imap hasn't created these directories yet. That will go away if you ever use notjunkmail.


    By the way, I've been getting (apparently) irrelevant errors about a missing config file in my ~/.spamassassin directory, errors that I don't see in your output. Would you please show us the result of this command on your server?


    ls -ld ~/.spamassassin


    username  wheel  136 Apr 25  2011 /Users/username/.spamassassin


    ls -lR ~/.spamassassin


    total 2520

    -rw-rw----  1 username  wheel    49152 Apr 25  2011 bayes_seen

    -rw-rw----  1 username  wheel  1241088 Apr 25  2011 bayes_toks


    By the way, it was pretty funny watching the Republicans turn themselves into Bayes' Theorem denialists this past month.

  • Jeff Hargrove Level 2 (235 points)

    Great! Thanks for your help!


    Ok, this is weird ... I tried those commands and I'm getting no such file or directory response! Should I be worried?

  • essandess Level 1 (15 points)

    Ahhh. That's it --- "rm -fr ~/.spamassassin". Thanks -- that makes my errors go away. No, you shouldn't worry -- I had a superfluous personal ~/.spamassassin directory from a prior install or just messing around. Deleting it is the right thing because as you can see above, OS X server has its own special place for the Bayes' database.

  • Jeff Hargrove Level 2 (235 points)

    I didn't do much, but was glad I could help a little after all the help you gave me!


    By the way, could the absence of that symbolic link affect spam being quarantined to a mail box? I'm having an issue where spam is not quarantined to the address I gave it.

  • essandess Level 1 (15 points)

    I ran the find command to see if Apple uses automatically. It isn't defaulted, but they've included all the necessary hooks in a plist file:


    find /Applications/ -type f -exec fgrep -l {} ';'

    /Applications/ ple.salearn.plist

    /Applications/ mgr_mail.bundle/Contents/MacOS/servermgr_mail


    These commands will set up your Server so that Spamassassin's Bayesian junk mail training occurs at 2:15 am every night:


    sudo cp /Applications/ pple.salearn.plist /System/Library/LaunchDaemons

    sudo launchctl load -w /System/Library/LaunchDaemons/

    sudo launchctl list | grep salearn

    -    0

    About quarantining, this is independent of training, so the lack of that symbolic linlk shouldn't have an effect.




    Mail>Preferences>Rules> Add Rule, Spamassassin, If <Message is Junk Mail>, then <Move Message> to mailbox <junkmail>.


    Aside from manually hitting the thumbs down on an email, that should completely automate the junkmail workflow on OS X Server.

Previous 1 2 3 Next