Mac OS X Server Mail

Information about the pros and cons of Apple's Mail server built in to OS X Server

Created by: spiderr, Last modification: 25 Sep 2007 (15:47 UTC)

Overview

With Mac OS X Server 10.4, Apple introduced new suite of mail server tools. Similar to Apple's use of Apache, these tools are all based on open-source tools that are workhorses for UNIX servers. Apple has also added a very nice GUI on top of these tools to make adminstering them very simple for the non-unix inclined. This GUI can be found in the "Server Admin" application, and click on "Mail". Even for shell geeks, the integration of the GUI to text config files is extremely useful for people with more important servers to run.

The Apple mail server uses postfix as it's primary smtp gateway. For virus protection, it uses amavisd which launches spamassassin for spam cleanup. This all comes preconfigured and ready to go out of the box.

Remote Administration

Everything can be done via the command line, however the OS X Server gui makes life painless. To run this remotely and free, do the following:

  1. Run OSXvnc on your server
  2. On your local machine, enter the following code into ~/.ssh/config
    
    <?php
    Host mail
    .foobar.com
            User johndoe
            Compression yes
            LocalForward 5901 localhost
    :5901
    ?>
    and the "ssh johndoe@mail.foobar.com".
  3. Once logged in, run your local VNC client, Chicken of the VNC is a great Mac VNC client. Open a connection to "localhost" and display "1"

You should get a window to the server. If not, first make sure you have a connection to port 5901 open on your local port. For example, try "telnet localhost 5901". If that does not connect, try a direct ssh port forwarding with"ssh -C -L 5901:localhost:5901 johndoe@mail.foobar.com"

Webmail support

While Apple does not include any webmail support, http://roundcube.net/ is a fabulous web 2.0 webmail application that works with IMAP and is comparable to yahoo/gmail. It can be setup up on an OS X Server machine in about 10 minutes.

Configuration

I recommend using dovecot for IMAP, however, I forget why. It can be installed using MacPorts, e.g. "sudo port install dovecot" (see below). Turn off

Spam Settings

  • You will want to tweak your spamassassin rules for your organization. Here is what I use and it is highly effective:
    
    <?php
    score AWL                
    -99.00

    score HELO_DYNAMIC_IPADDR  6.00
    score HELO_DYNAMIC_SPLIT_IP 4.00
    score RCVD_FAKE_HELO_DOTCOM 4.00
    score RCVD_NUMERIC_HELO   3.00

    score AS_SEEN_ON          2.00
    score BANG_OPRAH          2.00
    score DIET_1              9.99
    score DRUGS_ERECTILE      9.99
    score DRUGS_MUSCLE        9.99
    score MORE_SEX            9.99
    score MORTGAGE_PITCH      4.00
    score ONLINE_PHARMACY     4.00
    score STOCK_PICK          1.00
    score URG_BIZ             1.00

    score BAYES_00          0.0 0.0 0.0
    score BAYES_05          0.0 0.0 0.0
    score BAYES_20          0.0 0.0 0.0
    score BAYES_40          0.0 0.0 0.0
    score BAYES_50          0.0 0.0 0.0
    score BAYES_60          2.00
    score BAYES_70          2.60
    score BAYES_80          4.20
    score BAYES_90          4.30
    score BAYES_99          5.00

    score RCVD_IN_DBL       4.30
    score RCVD_IN_SBL       1.00
    score RCVD_IN_BONDEDSENDER 
    -5.00
    score HABEAS_SWE        0.00

    describe FOOBAR_CBTICKET subject is support ticket
    header   FOOBAR_CBTICKET Subject 
    =~ /\[foobar.com \#/i
    score    FOOBAR_CBTICKET -99.0

    describe FOOBAR_FOOBAR subject has foobar 
    (our company)
    header   FOOBAR_FOOBAR Subject =~ /foobar/i
    score    FOOBAR_FOOBAR 
    -3.0

    describe FOOBAR_ORDER Favored word
    Order
    header   FOOBAR_ORDER Subject 
    =~ /order/i
    score    FOOBAR_ORDER 
    -2.0

    describe FOOBAR_PHOTO Favored word
    Photo
    body     FOOBAR_PHOTO 
    /photo /i
    score    FOOBAR_PHOTO 
    -.5
    ?>
  • Under the "Filters" tab, I have "Minimum Junk Mail score:" set to 5, and Junk Mail Message should be: Bounced. Note this is a pretty aggressive setting to bounce. However, after running mail for 3 months without any false positives, I felt confident bouncing all this crap instead of filtering it to my spam folder.
  • Update junk mail database every 1 day (the default)
  • Install SPF and DomainKeys as instructed below. SPF is easy, DomainKeys is harder, and I have yet to get around to it.

Installing Pitfalls

Out of the Box, the mail suite is ready to go. However, there are few dangers.

CPAN upgrade trouble

  • CPAN can upgrade the Net:Server module which can cause trouble, as described in this forum post - OS X Server 10.4.x ships with Net:Server 0.87, however the latest is 0.96 - you can downgrade Net:Server with
    
    cpan> install R/RH/RHANDOM/Net-Server-0.90.tar.gz

Darwin Ports / Fink danger

  • If you use Darwin Ports or Fink, the shell PATH might be modified to use the ports version of perl and hence the ports version of the spamassassin modules.
  • Make sure your updates are installed and working. Per the Wiki link below, make sure you have updated all your perl modules and turned on DNSRBL, etc. For example,
    
    root$  sudo cpan -i HTML::Parser Net::DNS  Mail::SPF::Query IP::Country Razor2 Net::Ident IO::Socket::INET6 IO::Socket::SSL DBI LWP::UserAgent HTTP::Date Archive::Tar IO::Zlib

Virus Filtering with Amavis-d

Amavis-d is the virus scanning tool invoked by postfix.

See detailed explanation of amavisd.conf.

DNS Spam Prevention

There are two main options DomainKeys, and SenderID.
DomainKeys were invented by Yahoo, SenderID was invented by Microsoft. These are arguably competing techniques, however, implementing both seems to have no ill-effect. Given SenderID was invented by Microsoft, you can be assured Outlook Server SMTP gateways employ SenderID, and are unlikely to support DomainKeys any time soon. In early 2005 when these proposals came out simultaneously, they were seen as competing techniques. As time has passed, they are now seen as more complementary, and typically both are implemented.

DomainKeys

To use DomainKeys, typically a filter or "plugin" is needed for your SMTP gateway. There is a postfix filter that is fairly easy to install and configure. Several perl modules need to be installed:

cpan -i Crypt::OpenSSL::RSA Mail::Address MIME::Base64 Net::DNS Net::Server Test::More


SenderID (and SPF)

SenderID merged with a smaller group called Sender Policy Framework (SPF). SPF is a very simple mechanism for specifying which servers are valid for sending your email and is much simpler to implement than DomainKeys. Microsoft holds several patents in relation to the SenderID framework, however it released those patents in the "public domain" this past october. Beyond the typical cynicism of Microsoft's ulterior motives, SPF has a significant amount of technical criticism. Regardless, many major ISP's are using SPF to filter mail, including AOL (and RoadRunner) which has in some reports exclusively implemented SPF to some degree. (Spamassassin reports SOFT_FAIL reports from bogus .rr.com emails.) Spamassassin easily supports SPF with a few simple cpan installs.

The quickest way to get the DNS entries up and running is to follow the wizard.

Spam Filtering with SpamAssassin

SpamAssassin (SA) is launched with Amavis-d. There are several SA settings in /etc/amavisd.conf

More Options

  • ASSP Anti-Spam SMTP Proxy

Resources