Skip navigation

Spamassassin Junkmail and Notjunkmail Learning in Mountain Lion

5386 Views 34 Replies Latest reply: Nov 14, 2013 10:56 AM by scottl31 RSS
1 2 3 Previous Next
essandess Level 1 Level 1 (0 points)
Currently Being Moderated
Nov 4, 2012 2:40 AM

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
  • Kostas B Level 1 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

     

    Kostas

  • Jeff Hargrove Level 2 Level 2 (235 points)

    Hi,

     

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

     

    server:~ admin$ sudo /Applications/Server.app/Contents/ServerRoot/usr/libexec/spamassassin/learn_jun k_mail.sh

    Password:

    grep: /Applications/Server.app/Contents/ServerRoot/etc/dovecot/partition_map.conf: No such file or directory

    Can't determine mail store path from /Applications/Server.app/Contents/ServerRoot/etc/dovecot/partition_map.conf

     

    How can I fix this?

     

    Thanks

     

    Jefff

  • Jeff Hargrove Level 2 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/Server.app/Contents/ServerRoot/etc/dovecot/partition_map.conf

    ls: /Applications/Server.app/Contents/ServerRoot/etc/dovecot/partition_map.conf: 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

    default:/Library/Server/Mail/Data/mail

    server:~ admin$

     

    Is it the same file in both locations? Can I copy it into /Applications/Server.app/Contents/ServerRoot/etc/dovecot ?

  • Jeff Hargrove Level 2 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/Server.app/Contents/ServerRoot/usr/libexec/spamassassin/learn_jun k_mail.sh

    Learning what is junk mail

    --- sudo -u _amavisd /Applications/Server.app/Contents/ServerRoot/usr/bin/sa-learn --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/cur/1352283 956.M74829P7112.server.jeffhargrove.com,S=50277,W=50949:2,Sa

    --- sudo -u _amavisd /Applications/Server.app/Contents/ServerRoot/usr/bin/sa-learn --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352293 084.M102587P973.server.jeffhargrove.com,S=49035,W=50239

    --- sudo -u _amavisd /Applications/Server.app/Contents/ServerRoot/usr/bin/sa-learn --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352308 002.M789666P4300.server.jeffhargrove.com,S=6250,W=6422

    --- sudo -u _amavisd /Applications/Server.app/Contents/ServerRoot/usr/bin/sa-learn --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352371 908.M238607P32768.server.jeffhargrove.com,S=1362,W=1391

    --- sudo -u _amavisd /Applications/Server.app/Contents/ServerRoot/usr/bin/sa-learn --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352495 615.M32695P46666.server.jeffhargrove.com,S=16231,W=16452

    --- sudo -u _amavisd /Applications/Server.app/Contents/ServerRoot/usr/bin/sa-learn --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352495 629.M13461P46677.server.jeffhargrove.com,S=19331,W=19592

    --- sudo -u _amavisd /Applications/Server.app/Contents/ServerRoot/usr/bin/sa-learn --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352495 648.M683301P46689.server.jeffhargrove.com,S=13378,W=13563

    --- sudo -u _amavisd /Applications/Server.app/Contents/ServerRoot/usr/bin/sa-learn --dbpath /Library/Server/Mail/Data/scanner/amavis/.spamassassin --spam --no-sync < /Library/Server/Mail/Data/mail/45D0C5F6-DBC3-48A0-AAF9-7D69F79E0FEC/new/1352495 675.M29820P46709.server.jeffhargrove.com,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!

  • Jeff Hargrove Level 2 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?

  • Jeff Hargrove Level 2 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.

1 2 3 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (1)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.