Previous 1 2 3 Next 34 Replies Latest reply: Nov 14, 2013 10:56 AM by scottl31 Go to original post
  • Jeff Hargrove Level 2 Level 2

    This is really helpful!


    I was reading in Apple's advanced server admin manual that it was a default that the server will train junk mail at 2:15. Another let down ...


    I think you should be writing the unofficial manual for all of us novices.


    Any chance I could get your help about my quarantine problem? I think it is trying to deliver to the quarantine address, but fails, but don't know why.


    Again thanks for your time is getting spam training set up.





  • UptimeJeff Level 4 Level 4

    I've never been happy with bayes training since the old cyrus shared mailbox days.


    Users shouldn't need to redirect messages and sharing access to junkmail/notjunkmail imap accounts is cumbersome.


    Today, I tackled this with a quick script which does this:


    - Scans every mail user for 2 folders (junkmail/notjunkmail)

    - Feeds those messages to sa-learn, to train the bayes filters.


    I will add

    - purge the user junkmail/notjunkmail folders of messages > 30 days old.


    End result, users simply drag messages within their own imap account.

    The script can specifcy the standard 'Junk' folder so that client apps that filter to 'Junk' will contribute to the common bayes DB.


    This creates an easy to use training system which allows all users to contribute easily.

    Requires no server config, users only need to add their training folders.


    This feature may be added to spamtrainer in a future version.

  • Jeff Hargrove Level 2 Level 2

    This sounds great!


    Any chance that you might share this script with the community?

  • pterobyte Level 6 Level 6
    Servers Enterprise

    spamtrainer is already available for download at 

    It is compatible with Mountain Lion. It allows you to run it at any time you like, can backup/restore your bayes DB and purge learned messages.

    The additional features mentioned by UptimeJeff will be added in a future release.

  • Kostas B Level 1 Level 1



    Are there any instructions for setting this up?


    Best regards



  • pterobyte Level 6 Level 6
    Servers Enterprise



    once installed, "spamtrainer -h" or "man spamtrainer" will show you the available parameters. You will also find a PDF document on your desktop.




  • Kostas B Level 1 Level 1

    Thank you Alex!





  • Chris Goodwin Level 1 Level 1



    I installed this today and get errors when using the -d option as follows:


    server02:db admin$ sudo /usr/sbin/spamtrainer -d




    /usr/sbin/spamtrainer: line 1625: /usr/bin/cvt_mail_data: No such file or directory

    /usr/sbin/spamtrainer: line 1626: /usr/bin/cvt_mail_data: No such file or directory



    Starting spamtrainer...



    Training from user folders

    Learning SPAM...

    /usr/sbin/spamtrainer: line 1376: cd: /Library/Server/Mail/Data/mail//cur: No such file or directory

    /usr/sbin/spamtrainer: line 1391: cd: /Library/Server/Mail/Data/mail//new: No such file or directory

    Learned new SPAM (junk mail)

    Learning HAM...

    /usr/sbin/spamtrainer: line 1435: cd: /Library/Server/Mail/Data/mail//cur: No such file or directory

    /usr/sbin/spamtrainer: line 1450: cd: /Library/Server/Mail/Data/mail//new: No such file or directory

    Learned new HAM (not junk mail)

    Syncing SpamAssassin Database

    Displaying SpamAssassin Database Stats

    0.000          0         14          0  non-token data: spam

    0.000          0         63          0  non-token data: ham

    Deleting learned HAM and SPAM


    Output produced by spamtrainer Version 1.9.8



    The database doesn't appear to be updated and the junk / notjunk mail is not deleted.


    Appears to run OK and updates the database if run with no options.


    This is with a standard mail setup (nothing moved to different locatins, junkmail and notjunkmail users exist and mailboxes can be accessed through the Mail client.


    Any thoughts??

  • pterobyte Level 6 Level 6
    Servers Enterprise

    What puzzles me is that you say it runs fine without the -d flag. The output you show is from a section where the -d flag doesn't count.


    Looks like a path problem to me. Any chance you have spaces in volume or path names somewhere?


    Could you mail me your dovecot configuration files?

  • Chris Goodwin Level 1 Level 1

    Yep - space in the boot volume name (Server HD) as delivered. Is renaming that going to have any effects on any services?


    Which dovecot files in particular are you referring to? (I'm still trying to find my way around the new architecture having move from using Snow Leopard Server - new setup not migration).

  • pterobyte Level 6 Level 6
    Servers Enterprise

    Space in Boot volume path is not a problem usually.


    I think I found an obscure bug. Can you try and run spamtrainer again. You should be prompted to update to 1.9.9 which should fix it. Sorry about that and thanks for the feedback.





    P.S. Don't need it anymore, but for reference, the conf files are in /Library/Server/Mail/Config/dovecot/

  • Chris Goodwin Level 1 Level 1

    That seems to have done the trick!!


    Excellent service (as usual).


    Just need tosetup the auto run and hopefully good to go.


    Many thanks,



  • Kostas B Level 1 Level 1

    Sorry for this, but I need some clarification:


    "When run, it will read the designated HAM and SPAM mailboxes, update the SpamAssassin databases and delete mail that has been learned from".


    Suppose I create these mailboxes using: spamtrainer -p mymailpartition -j myjunkmailbox -n mynotjunkmailbox -d


    1. How the users are aware of these mailboxes? Or is this the messages confirmed as "Junk" in their Mail client.


    2. What -d (delete processed mail) means?


    3. I have set all the marked as junk to redirect to a specific mail account and the users check this mailbox for any false marked items. Can they "whitelist" addresses from there?


    Best regards



  • pterobyte Level 6 Level 6
    Servers Enterprise

    spamtrainer will not create any mailboxes for you. The -p -j and -n parameters are only so you can point spamtrainer to different accounts. spamtrainer makes the same assumptions Apple's learn_junk_mail script does. It also uses the same backend software - spamassassin's sa-learn.

    It is simply more flexible because you can give it different parameters if you have customised your system. It also allows you to delete spam and ham messages that you put in the junkmail and notjunkmail mailboxes after it has learned those messages.


    Running spamtrainer or learn_junk_mail will train the bayes DB. It is not a whitelist. Whitelisting can be done in amavisd.conf or a configuration file like




  • bdemore Level 1 Level 1

    Oddly when I run "sudo serveradmin settings mail:imap | grep junk" on a brand new 10.8 Server install, I receive the following:


    mail:imap:junk_mail_userid = ""

    mail:imap:not_junk_mail_userid = ""


    I've tried to set them manually with the following command: 


    sudo serveradmin settings mail:imap:junk_mail_userid = "junkmail"


    This command does not seem to change the status at all.  Any advice?


    Thanks in advance.