As Apple continues to dumb-down their Server offering, spam filtering becomes more and more difficult. Using MailCleaner is a simple way to block most spam, is easy to install manage, provides web-based administration and user accessible quarentine management, and is an invaluable tool if you host your own mail. MailCleaner is the chinese wall to block the mongol hoardes of spammers trying to reach your mail server.
MailCleaner offers a free Community Edition as a virtual machine which can be downloaded and hosted on a server under VMware Fusion. This makes keeping a backup copy as easy as making a copy of the virtual machine file. If you have the wherewithal, consider purchasing the commercial version.
The instructions on how to setup are pretty straightforward.
After you have MailCleaner setup and working, be sure to:
- Change your domain MX records to only include the static WAN IP of your mailcleaner instance, as this is where you will now be receiving all inbound mail
- Open port 25 on your firewall so that the mailcleaner instance may accept SMTP connections
- Block port 25 on your firewall to your mail server, so that spammers cannot bypass Mailcleaner. You can leave ports for secure IMAP, secure POP and other ports open on your mail server so that users may still use mail services remotely.
- You'll most likely want to leave port 587 (SMTPD) open to your mail server so that remote users may send email via SMTP. If using postfix, be sure your smtpd_sender_restrictions are set properly otherwise you will be an open relay. Strangely, the web based mail server test tools only seem to check port 25, so your warning could be a zillion smtpd connections from foreign servers connecting directly to your mail server (although they should only be able to reach mailcleaner). Be sure you have a suitable entry for smtpd_sender_restrictions in /etc/postfix/main.cf ie.
smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, permit
You will periodically want to update MailCleaner. Shutdown and make a backup copy of your VM in case you screw something up, then login from the command line as root and follow the update instructions.
How To Protect Against Joe Jobs / Backscatter
Joe Jobs or Backscatter is when a spammer uses one of your email addresses as the FROM for their spam. Although spam never traversed your server, you can be flooded with hundreds or thousands of bounce messages from a variety of third party servers bouncing the spam to you.
MailCleaner uses SpamAssassin as one of its filtering tools, and there's a ruleset designed to capture backscatter: VBounceRuleset. This ruleset identifies bounce messages, checks the headers to see that your mail server hostname appears in any RECEIVED block, and filters out any emails which did not originate from your mail server.
To install, shutdown and make a backup copy of your VM in case you screw something up, then login from the command line as root and follow the installation instructions.
Afterwards, be sure to create a sample bounce message and test to ensure that it works as expected. See this thread for testing instructions.
Adding More RBLs
Realtime Black Lists (RBLs)are a very effective way to stop spam before it is accepted by MailCleaner. Here are instructions on how to add a bunch of RBLs to MailCleaner in the Configuration:Anti-Spam:PreRBLS list, but consider only adding only those you review to ensure they are still active and that your usage falls within their terms of service.
To see which RBLs might be most effective, lookup the sending mail server in your spam email headers, and as quickly as possible to see which RBLs are fastest to detect.
If you have SPF checking enabled and have other mail servers which act as backup MX servers for your domain, you need to disable SPF checking of those servers so that MailCleaner will accept the email, avoiding errors like this:
To do this, add the IP or network range (eg: 0.0.0.0/24) for the backup MX server(s) in Configuration -> SMTP -> Don't check this hosts.
DuoCircle Backup MX servers
DuoCircle, formerly known as DynDns or MailHop, provides backup MX services, as well as many other services. You can find a list of their delivery IP addresses here: https://support.duocircle.com/support/solutions/articles/5000524218-ip-addresses-for-firewalls
Here is a list of IP addresses as of 3/2/2016:
18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124
MailCleaner strongly disagrees with whitelisting of email addresses or domains. If you are a big ISP using their tools, this probably makes sense as blindly accepting any email might go unnoticed, but for smaller businesses this is a practical way to allow receipt of email from their values customers/companies who may have misconfigured mail servers &etc.
How to Turn On
For whitelists to actually work, you must turn it on in TWO places in the UI:
- Configuration: Anti-spam: Global Settings: [X] Enable access to whitelists
- Configuration: Domains: (Each domain you want to have whitelists) : Filtering : [X] Enable whitelists
You can then add whitelist entries at a global or domain scope.
Proper Syntax for Whitelist Entries