Configuring Spam Assassin In Mac OS X Lion Server

The built-in message hygiene in Lion Server is provided by Spam Assassin and clamav (amavis). Lion Server’s Server Admin application has an easy-to-use way of configuring some of the more basic settings for Spam Assassin. Spam Assassin’s rules are configured in /etc/mail/spamassassin/local.cf. If you open this into a standard text editor then you can insert blocks that are rules. Each rule has the ability to either locate text within a header (such as an email address), a subject or in the text of an email. To use Spam Assassin to block messages that have the word viagra in them, for example, you would insert the following block:

body NO_MORE_VIAGRA /viagra/i
score NO_MORE_VIAGRA 10
description NO_MORE_VIAGRA messages that contain the word Viagra

The first line looks for any email with the word viagra. The second line assigns it a score of 10 and the third gives us an easy to read description. You can also effectively whitelist email addresses or words. For example, the following would subtract 100 from the score of any email sent from my iCloud account:

header FROM_KRYPTED ALL =~ /krypted@me.com/i
score FROM_KRYPTED -100
description FROM_KRYPTED messages from krypted

The above block is similar to the previous one, but instead of adding to the likelihood that the message is spam we’re subtracting so much that even if I’m talking about viagra, the message still wouldn’t be flagged as spam.

Once you’ve entered the rules that you feel are needed for your environment, run the spam assassin command followed by the –lint option:

spamassassin --lint

6 Comments

  • Jon Rasmussen
    March 29, 2012 - 5:19 am | Permalink

    I have enjoyed your study of the new server and specifically mail. We started using e-mail on the Mac in 1990, 5 years before the internet was popular. We have continued to maintain an internal e-mail server. Recently in Snow Leopard they took away the ability to e-mail to security groups set up in WorkGroup Manager. We had to create an e-mail address and forward to it to e-mail to a group. Now in Lion they have taken away the ability to auto-forward messages (server side) from one person to another. Is there a way to get this back. Has it simply moved to a web interface?

    Going to buy your Lion server book when it comes out. Looking forward to it.

    Thank you again for your good work.

    • June 28, 2012 - 5:19 pm | Permalink

      Yup, it’s server-side in the webmail interface. Thanks for the kind words!

  • Troy
    June 24, 2012 - 9:54 am | Permalink

    This gave me an error. I can only assume you left out some information as to where in the local.cf this should go or possibly if it needed any special formatting. Lion 10.7.3

    • June 28, 2012 - 8:53 pm | Permalink

      Interesting. I was able to put it first and last and it didn’t error. Can you send me an example?

  • Kostas Backas
    October 19, 2012 - 2:21 am | Permalink

    Good!

    How do we whitelist a whole domain, and how can we enable users to whitelist or blacklist addresses?

    Best regards

    Kostas

  • Matt Domenici
    October 27, 2012 - 9:24 am | Permalink

    Will you be updating this article for Mountain Lion Server?

    Also, have you seen any issues on upgrade with sa-learn not running?

  • Comments are closed.