Back in 2014 I wrote a good chunk of the Zimbra Anti-Spam Strategies community wiki. In the intervening six years, a lot has changed, but unfortunately email remains the number one attack vector for malware, phishing, whaling and other scams.
In this blog post we describe how we supplement the various open-source anti-spam capabilities that ship with Zimbra with three commercial block list providers for a low-cost, high-impact solution.
Once again, we cannot overemphasize the need for periodic end-user training. Anti-spam will never be perfect, so users need to be trained when to pause, take a deep breath and think before they open or reply to an email. When a user receives an email from someone they know, but the email seems suspicious, DO NOT REPLY to the email! Instead, train your users to FORWARD the email to the (alleged) original sender. This is because the “From:” portion of an email can be easily forged, but the recipient will have the correct email address for the sender in their Address Book.
This “forged sender” technique is typically how those emails purporting to be from the CFO and ordering expediting payment to a vendor (really the scammer who sent the email in the first place) cause so much trouble; the poor accounting clerk thinks s/he is replying to the CFO, but is really replying to the scammer.
Lastly, in most of the recent email hacks with which I am familiar, two-factor authentication would have prevented the exploit from being deployed, so we are strongly encouraging our customers to deploy two-factor authentication — it’s really not as inconvenient to use as most people presume.
December 2020 Sidebar – Email Engagement and Deliverability
Due to COVID, in 2020 many sources (and our own logs confirm) that overall email volume has about doubled. As a result, the major free email services (Gmail, Yahoo, Outlook.com etc.) have gotten much more strict about classifying email, your domain, and your server as a potential spam source. They do this by looking at “engagement“, for example: Does the recipient open your messages or just put them in the Trash? Even if they open the messages, do they reply? If your “engagement” is low, your server’s IP address and your domain are more likely to be be blocked, even if you are not sending what would normally be considered “spam”.
To avoid getting low engagement scores (which can lead to being blocklisted), and improve overall deliverability, there are a few simple rules:
- Prune your lists:
- Send emails only to valid email addresses: If you get a bounce back or a deferral, investigate and remediate before you attempt to send again.
- Send emails only to people who want them: If recipients are not responding, send them an email telling them you will email them less frequently (unless they reply).
- Ensure public DNS is correct and optimized:
- An accurate SPF-formatted TXT record with a “hard fail” helps a lot.
- Doing DKIM signing protects your domain from being spoofed, and also helps with your reputation.
- Configuring a DMARC record helps even more, especially if you use a service (we use Dmarcian) to receive and analyze the DMARC reports for you.
- Subscribe to a blocklist tracking service (we use RBL Tracker).
December 2020 Changes Summary
In the latter half of 2020, we retested Spamhaus and got better results than when we tested in 2018 and 2019. During that same time, we noticed our logs started showing more lookup failures with Barracuda’s free blocklist. A call to Barracuda Support surfaced that their infrastructure was being upgraded due to increased email volumes, so while we still love the free block list provided by Barracuda (but be sure to register your IP addresses before trying to use it), nowadays, our three favorite commercial (i.e. paid) block list providers are invaluement, uribl and Spamhaus.
In addition to including Spamhaus configurations (for their commercial paid products), we also updated the custom SpamAssassin configuration file that contains adjusted scores and other configurations to improve spam filtering and reduce false positives.
Since December 2020, we have also updated this post with additional adjustments to our SpamAssassin configurations and scores.
Anti-Spam Quick Level Set: Terminology, Approach and Techniques
Here are some key terms and concepts to make sure we are all on the same page:
- Gray Mail – Email that technically isn’t spam, but that most users don’t want. You downloaded a whitepaper and had to give up your email address, so now you are receiving all kinds of offers via email that you technically authorized when you accepted the terms and conditions to be able to download that whitepaper.
- Spam – For our purposes, “spam” is email that has been determined to be junk. In the United States, the CAN-SPAM Act has a more rigorous definition. In countries covered by the GDPR, “UCE” or Unsolicited Commercial Email is even more heavily restricted. If an email is unequivocally junk, Zimbra deletes it. If it is marginally junk, Zimbra can prepend the Subject line with a warning and place it in the user’s Junk folder. The threshold between deletion and sending on is adjustable.
- Block List – A third-party service that Zimbra can use to identify IP addresses and domains that are known spam sources, either because they are just bad guys (in the eyes of the block list provider) or because they are nice guys that have been hacked. Some block lists are very aggressive in their listing policies; others less so. There are three types of block lists:
- Left-hand side block lists for checking IP addresses (“RBLs”);
- Right-hand side block lists for checking domains (“RHSBLs”), and;
- URI block lists for checking links within an email body (“URIBLs”).
- False Positive – A legitimate email incorrectly identified as spam. Block Lists are rated on their frequency of false positives. Typically, the higher the rate of false positives, the less spam a block list will allow. This trade off between efficacy and accuracy warrants a discussion with management. Customers that have high requirements for both low false positives and near-zero spam are typically prospects for additional commercial third-party services, like Mimecast.
- Postfix – The open source MTA (Mail Transfer Agent) software included with Zimbra that accepts email from, and delivers email to, other mail servers and Zimbra mailboxes.
- Amavisd – The open source software that is tightly integrated with Postfix, and which processes emails through SpamAssassin and ClamAV before allowing Postfix to deliver them.
- SpamAssassin – A powerful open source software that ships with Zimbra and which performs hundreds of tests on an email. Each test result adds a positive (bad) or negative (good) score to an email. At the end of the exercise, SpamAssassin adds up all of the tests’ individual scores to get a combined score for the email. Scores above a certain threshold result in the email being classified as Spam. The thresholds at which SpamAssassin marks an email as Junk and delivers it to the end user, or deletes it outright are adjustable.
- ClamAV – The open source anti-virus engine that ships with Zimbra and which is preconfigured to update itself.
Our anti-spam techniques comprise deploying sensible configuration adjustments to the the open source softwares that ship with Zimbra, supplemented with three paid third-party blocklists. Budget US$1.00 to US$4.00 per mailbox per year for third-party black lists to use within Zimbra, and you will be all set. If you need more enhanced email security services like data loss prevention, end-to-end encryption, user-managed quarantines, compliance assurance and email continuity so users can send and receive emails even when Zimbra is down, you are a candidate for a Mimecast subscription.
The rest of the article presumes you have already signed up for subscriptions from invaluement, uribl and Spamhaus (or from alternative providers you deem better suited to your environment) and want to deploy their services in Zimbra.
Technique #1 – Outright Blocking With Postscreen
Zimbra’s Postfix now ships with Postscreen, a kind of inbound email firewall. Postscreen effectively blocks bad guys without putting any strain on the the Zimbra server. The Zimbra Postscreen wiki describes this tool, and how to configure it, in great detail. But the wiki recommends some very aggressive blocklists for the zimbraMtaPostscreenDnsblSites variable, and our experience has been that using the blocklists listed in that wiki cause a lot of false positives. As a result, we only use the free list provided by Barracuda Central (thank you Barracuda!) and one of our paid provider’s lists. To simplify, we ran as the Zimbra user:
zmprov mcf zimbraMtaPostscreenDnsblSites 'b.barracudacentral.org=127.0.0.2*7' zimbraMtaPostscreenDnsblSites 'sip-sip24.<your-account-code>.invaluement.com=127.0.0.2*6' zimbraMtaPostscreenDnsblSites '<your-account-code>.zen.dq.spamhaus.net=127.0.0.[2..255]
zmprov mcf zimbraMtaPostscreenDnsblAction enforce
zmprov mcf zimbraMtaPostscreenGreetAction enforce
zmprov mcf zimbraMtaPostscreenNonSmtpCommandAction drop
zmprov mcf zimbraMtaPostscreenPipeliningAction enforce
zmprov mcf zimbraMtaPostscreenDnsblTTL 5m
zimbra@zimbra:~$ zmprov gcf zimbraMtaPostscreenDnsblSites
zimbraMtaPostscreenDnsblSites: b.barracudacentral.org=127.0.0.2*7 zimbraMtaPostscreenDnsblSites: sip-sip24.<our_account_number>.invaluement.com=127.0.0.2*6
Postscreen is really resource-efficient. It doesn’t require a lot of RAM, disk nor CPU cycles to implement. But this is where we recommend using only blacklists that have a very, very low known rate of “false positives”. And this screen is for the IP address of the sending server onlyThe Third Strategy – Front Door Blocking Via DNS Checks
Within a few minutes, Zimbra’s zmconfigd configuration daemon will pick up the above changes and reload Postfix appropriately.
Technique #2 – Outright Blocking With Postfix DNS Protocol Checks
Outside email servers trying to send you email should behave appropriately and be configured according to published and accepted standards. Most are not, and often for acceptable reasons. Zimbra’s Postfix allows you to check a number of these via settings in the Admin Console (Home > Configure > Global Settings > MTA), but all but two of these checks can generate frequent false positives. The two checks that don’t generate false positives, but which will block a lot of spam are:
zmprov mcf +zimbraMtaRestriction reject_non_fqdn_sender
zmprov mcf +zimbraMtaRestriction reject_unknown_sender_domain
The “reject_unknown_sender_domain” according to the Postfix documentation, performs some specific checks to ensure the sender’s domain actually exists in public DNS. If the sender’s domain doesn’t exist, the email is not accepted. Similarly, the “reject_non_fqdn_sender” check will reject the email if the MAIL FROM isn’t a properly-formed email address. “johnny@hosting” would get rejected by the non-fqdn check and “firstname.lastname@example.org” would get rejected by the unknown sender domain test because (at least as of this writing) the domain “hosting666.com” doesn’t exist.
Technique #3 – Outright Blocking of Bad Sending Servers
Now we start using blocklists within Postfix, and their are two kinds: “RBLs” or left-hand-side blocklists, and RHSBLs or right-hand-side blocklists. RBLs list IP addresses; RHSBLs list domains. Different blocklist providers have different philosophies about how IP addresses and domains get listed. Some are forthcoming and transparent; others less so. Some are clearly very aggressive in their listing methodologies and fully acknowledge they will cause some “false positives” periodically. Some have clear rules for delisting; others do not. So before you choose any blocklists to use, be sure you make sure the culture of the blocklist aligns with the culture of your company’s sensitivity to false positives. Here’s what we do (please be sure to substitute your own invalument account code first!):
zmprov mcf +zimbraMtaRestriction "reject_rbl_client b.barracudacentral.org"
zmprov mcf +zimbraMtaRestriction "reject_rbl_client sip-sip24.<account_code>.invaluement.com"
zmprov mcf +zimbraMtaRestriction "reject_rbl_client psbl.surriel.com"
zmprov mcf +zimbraMtaRestriction "reject_rbl_client cbl.abuseat.org"
zmprov mcf +zimbraMtaRestriction "reject_rbl_client <account_code>.zen.dq.spamhaus.net"
Included between the three free blocklists above, we use one paid blocklist from invaluement and one from Spamhaus. We spent more than nine months testing a lot of RBL providers, and invaluement came to the top based on their ability to catch spam sources really early on (before many of the majors). They have a very low false positive rate and their pricing is very fair. Lastly, they also provide URIBL checking too (but we’ll get to that in a little bit…)
Those five RBLs together we have found do a fantastic job of blocking spam from known bad IP addresses.
Technique #4 – Outright Blocking of Bad Sending Domains
So far we’ve used Postfix’s Postscreen and Postfix itself, with some RBL add-ins, to block spam from known bad IP addresses. The next step is to use Postfix to block spam from known bad domains. For, that we use RHSBLs from one of our paid blocklist providers (again, be sure to use your account code after you subscribe):
zmprov mcf +zimbraMtaRestriction "reject_rhsbl_client <account_code>.df.uribl.com"
zmprov mcf +zimbraMtaRestriction "reject_rhsbl_client uri.<account_code>.invaluement.com"
zmprov mcf +zimbraMtaRestriction "reject_rhsbl_reverse_client <account_code>.df.uribl.com"
zmprov mcf +zimbraMtaRestriction "reject_rhsbl_reverse_client <account_code>.dbl.dq.spamhaus.net"
zmprov mcf +zimbraMtaRestriction "reject_rhsbl_reverse_client <account_code>.zrd.dq.spamhaus.net"
zmprov mcf +zimbraMtaRestriction "reject_rhsbl_sender <account_code>.df.uribl.com"
zmprov mcf +zimbraMtaRestriction "reject_rhsbl_sender <account_code>.dbl.dq.spamhaus.net"
zmprov mcf +zimbraMtaRestriction "reject_rhsbl_sender <account_code>.zrd.dq.spamhaus.net"
Technique #5 – Outright Blocking of Certain Attachments
By default, Zimbra does not block what could be dangerous email attachments, like Visual Basic scripts, Windows Registry edits etc. So, we need to block those attachments and let the System Administrator and the recipient know we have done so. Zimbra by default also blocks encrypted attachments, but it is more common these days that many users email password-protected files to each other, so in our systems we allow this. To effect these changes we run:
zmprov mcf +zimbraMtaBlockedExtension asd
zmprov mcf +zimbraMtaBlockedExtension bat
zmprov mcf +zimbraMtaBlockedExtension cab
zmprov mcf +zimbraMtaBlockedExtension chm
zmprov mcf +zimbraMtaBlockedExtension cmd
zmprov mcf +zimbraMtaBlockedExtension com
zmprov mcf +zimbraMtaBlockedExtension cpl
zmprov mcf +zimbraMtaBlockedExtension cpgz
zmprov mcf +zimbraMtaBlockedExtension dll
zmprov mcf +zimbraMtaBlockedExtension do
zmprov mcf +zimbraMtaBlockedExtension exe
zmprov mcf +zimbraMtaBlockedExtension hlp
zmprov mcf +zimbraMtaBlockedExtension hta
zmprov mcf +zimbraMtaBlockedExtension html
zmprov mcf +zimbraMtaBlockedExtension js
zmprov mcf +zimbraMtaBlockedExtension jse
zmprov mcf +zimbraMtaBlockedExtension lnk
zmprov mcf +zimbraMtaBlockedExtension ocx
zmprov mcf +zimbraMtaBlockedExtension pif
zmprov mcf +zimbraMtaBlockedExtension reg
zmprov mcf +zimbraMtaBlockedExtension scr
zmprov mcf +zimbraMtaBlockedExtension shb
zmprov mcf +zimbraMtaBlockedExtension shm
zmprov mcf +zimbraMtaBlockedExtension shs
zmprov mcf +zimbraMtaBlockedExtension vbe
zmprov mcf +zimbraMtaBlockedExtension vbs
zmprov mcf +zimbraMtaBlockedExtension vbx
zmprov mcf +zimbraMtaBlockedExtension vxd
zmprov mcf +zimbraMtaBlockedExtension wsf
zmprov mcf +zimbraMtaBlockedExtension wsh
zmprov mcf +zimbraMtaBlockedExtension xl
zmprov mcf zimbraMtaBlockedExtensionWarnAdmin TRUE
zmprov mcf zimbraMtaBlockedExtensionWarnRecipient TRUE
zmprov mcf zimbraVirusBlockEncryptedArchive FALSE
Technique #6 – Email Content Checking
So far Postfix/Postscreen have done all of the work via low-cost DNS lookups, and all of the checks have been binary: Is the sender on a blocklist? Yes? Drop the connection or don’t accept the email. For emails which have not yet been rejected, Postfix will now accept the email and pass it off to Amavisd for processing.
Zimbra ships Amavisd preconfigured to process emails through ClamAV and SpamAssassin. Amavisd can be configured to process emails through additional third-party services (configuring that is beyond the scope of this article). Once processed, the emails are (a) delivered to the recipient (either because the email is clean, or because the email has been marked as spammy and put in the user’s Junk folder), (b) placed in a quarantine or (c) just discarded if the email’s spam score is off the charts. We control the “discard/spam/not spam” thresholds and the Subject prepend for spammy emails like so:
zmprov mcf zimbraSpamKillPercent 75
zmprov mcf zimbraSpamTagPercent 19
zmprov mcf zimbraSpamSubjectTag "** CAUTION! SUSPICIOUS EMAIL **"
At least on Ubuntu, a basic install of the operating system doesn’t install as many file extraction tools and Perl libraries as Amavis and SpamAssassin would like. To install some additional tools Amavis can use to check the contents of many unencrypted archives, we run as the root user the following command, which also installs Pyzor and Razor.
apt-get install libgeo-ip-perl libgeo-ipfree-perl libnet-patricia-perl lrzip lzop arj zoo rar unrar p7zip-full p7zip-rar tnef ripole nomarch arc pyzor razor
Pyzor and Razor are two crowd-sourced anti-spam tools that are especially effective at blocking those “Awesome Vacation Rental!” and similarly abusive subscription-list-based spam emails. But, after we install the Pyzor and Razor packages above, we next need to configure them by running:
su - zimbra
pyzor --homedir /opt/zimbra/data/amavisd/.pyzor discover
razor-admin -home=/opt/zimbra/data/amavisd/.razor -create
razor-admin -home=/opt/zimbra/data/amavisd/.razor -discover
razor-admin -home=/opt/zimbra/data/amavisd/.razor -register
Moving on, Zimbra’s log file “/var/log/zimbra.log” contains a lot of good information about which emails are accepted/rejected, but no detail on the components of an email’s spam score. To get that detail (so we can tune things later if needed, and explain to a disgruntled user why an email was marked as spam) we need to bump up Amavis’s logging level from the default 1 to 2, like so:
zmprov mcf zimbraAmavisLogLevel 2
Not all of Amavis’s configurations are adjustable via Zimbra Global Config variables. Zimbra ships Amavis’s config template file as “/opt/zimbra/conf/amavisd.conf.in”. Every time Zimbra (or just Amavis) is restarted, Zimbra’s zmconfigd configuration daemon reads this template file and rewrites the actual amavisd.conf file right before starting the amavisd service. We need to make a few minor changes…
First, SpamAssassin skips over emails with large bodies, on the premise that spammers won’t waste time sending big emails. Wrong. Spammers just pad emails with a bunch of invisible junk to avoid getting their emails’ contents checked. So we need to empower SpamAssassin to check those larger emails.
The second thing we need to do to amavisd.conf.in is whitelist Zimbra’s Daily Mail Report, else the lists of bad domains that got blocked will cause the Daily Mail Report itself to be marked as Spam.
To effect both of those changes, as the zimbra user edit “/opt/zimbra/conf/amavisd.conf.in” in two places:
# ORIGINAL LINE BELOW - CHANGES TO THIS FILE WILL NOT SURVIVE ZIMBRA UPGRADES
# $sa_mail_body_size_limit = 512*1024; # don't waste time on SA if mail is larger
$sa_mail_body_size_limit = 1024*1024; # don't waste time on SA if mail is larger
Lower down in the file, look for the following lines and insert a prescore for the virus notifications sender email you use (example in green):
'returns.groups.yahoo.com' => -3.0,
'email@example.com' => -3.0,
'firstname.lastname@example.org' => -10.0,
lc('lvs-users-admin@LinuxVirtualServer.org') => -3.0,
lc('owner-textbreakingnews@CNNIMAIL12.CNN.COM') => -5.0,
# soft-blocklisting (positive score)
'email@example.com' => 3.0,
'.example.net' => 1.0,
Now that SpamAssassin is going to be asked to process a lot more, and bigger emails, Amavis needs a RAM disk for SpamAssassin to do that work. RAM disk provisioning varies from distribution to distribution, but on Ubuntu 16.04 with Zimbra 8.8.x and where the zimbra user’s UID and GID are both 999, you can add the following line to /etc/fstab to create a 1GB RAM disk:
tmpfs /opt/zimbra/data/amavisd/tmp tmpfs defaults,noexec,nodev,nosuid,size=1024m,mode=750,uid=999,gid=999 0 0
For most Zimbra MTAs, a 1GB RAM disk will be large enough. But if you have more than the standard amavis processes running, or you allow large file size attachments, it’s possible you may need a larger RAM disk. Ralf Hildebrandt, the author of the seminal Book of Postfix, has a blog that contains the RAM disk sizing formula you can use.
Note that Amavis cannot be running if you want to implement this without a reboot. To do so on a live Zimbra system you would do:
su - zimbra
ls /opt/zimbra/data/amavisd/tmp <= This directory should be empty with Amavis stopped
exit <= To go back to being root
df -h <= To make sure the mount succeeded
chown -R zimbra.zimbra /opt/zimbra/data/amavisd/tmp
su - zimbra
ls /opt/zimbra/data/amavisd/tmp <= This directory should now have a few "amavis-2019..." directories
The SpamAssassin project periodically updates the hundreds of rules SpamAssassin uses, but Zimbra by default does not update SpamAssassin’s rules, so we need to tell Zimbra to update SpamAssassin periodically and restart SpamAssassin after an update:
zmlocalconfig -e antispam_enable_rule_updates=true
zmlocalconfig -e antispam_enable_restarts=true
ClamAV takes care of updating itself by default; Zimbra runs ClamAV’s companion “freshclam” service periodically to update ClamAV’s virus definitions. Unfortunately, the default update frequency is too infrequent for us, so to update the virus definitions every two hours we run:
zmprov mcf zimbraVirusDefinitionsUpdateFrequency 2h
Now that Amavis, SpamAssasin and ClamAV are ready to zoom, we need to tweak SpamAssassin to use our paid blocklist providers, and to prevent some common false positives.
invaluement, uribl.com and Spamhaus provide customers with SpamAssassin configuration files that should be placed in /opt/zimbra/data/spamassassin/localrules. These files cause SpamAssasin to perform the additional/changed email content scanning tests supported by the providers. In addition, non-Zimbra files in this directory are left intact by Zimbra’s installer, so Zimbra Patches and indeed Zimbra version upgrades will not “break” your SpamAssassin customizations.
We do need to do one more thing to customize SpamAssassin… If you have not already done so, as the zimbra user run:
Add the following lines to the above zzsauser.cf file:
score DOS_OUTLOOK_TO_MX 0
score TO_EQ_FM_DIRECT_MX 0
score RCVD_IN_PBL 0.1
score RDNS_NONE 0.1
score FREEMAIL_FORGED_REPLYTO 4.0
score MALFORMED_FREEMAIL 4.0
score FORGED_GMAIL_RCVD 4.0
score FREEMAIL_REPLY 2.5
score FREEMAIL_REPLYTO 2.5
score RCVD_IN_RP_RNBL 4.0
score FROM_FMBLA_NEWDOM 2.5
score FROM_NEWDOM_BTC 3.0
score __RCVD_IN_DNSWL 0.001
score BAYES_00 0
score BAYES_05 0
score RAZOR2_CHECK 2.0
score PYZOR_CHECK 2.0
originating_ip_headers X-Yahoo-Post-IP X-Apparently-From
originating_ip_headers X-SenderIP X-AOL-IP
The first three lines containing “_MX” and “_PBL” SpamAssassin tests have default scores that are really high. These tests will fire when a user with Zimbra Connector for Outlook sends emails, so we need to adjust the scores of those tests down to zero. Otherwise, emails sent from Outlook using the Outlook Connector will often be flagged as spam. The PBL test however is used by other tests, so (see below) we set this to a small value.
The next test, for Reverse DNS, also comes with a default high score, and a quick Google search will yield a lot postings complaining about the high false positive rate from this test. We can’t set this RDNS_NONE score to zero, because several other useful SpamAssassin tests depend on RDNS_NONE. But, we can set the score for this test to be really small, so it won’t result in any false positives.
The five forged freemail tests we give a higher score to than the default SpamAssassin score, because we see that spammers will send junk from a “real” email server, but forge the reply-to to point to a gmail, hotmail etc. mailbox. This is so that the spammer can receive replies to an email account that was not the source of the spam.
The RCVD_IN_RP_RNBL test queries a blocklist maintained by ReturnPath, who’s business centers around senders’ mostly positive reputations. You have to work very hard to get on their blocklist, and as such it has a very low false positive rate, so we boost the default score that SpamAssassin otherwise provides. More info at https://senderscore.org/.
The next two “NEWDOM” tests add points for emails being sent from brand new domains. Spammers often register new domains and send out spam until the right-hand-side blocklists start blocklisting them. These two tests cover that gap, but may cause false positives for legitimate email being sent from domains which have been registered in the past few days. But, considering it usually takes a day or two for legitimate users to set up their email after they register their domain, we consider the risk of false positives from these tests to be extremely low.
The last test, “__RCVD_IN_DNSWL” has a reputation for generating false positives, but at least two other tests depend on it, so we give this test the smallest score possible. (If we gave it a zero score, the other tests dependent on this test would not happen.)
SpamAssassin also comes with a Bayes filtering engine. Bayes works great for some but not for others. In my case, I found a lot of spam-like emails would NOT get flagged as spam because the Bayes “ham” tests would add a few negative points to the email’s overall score, keeping the problematic email from being flagged as spam when it really should be. I used to just turn Bayes filtering off by setting “use_bayes” to zero to fix this. But now what I do is to remove the negative scores from when Bayes thinks the email is ham.
The next few lines are the IP addresses of the servers in a multi-server Zimbra hosting farm, and not just the MTA servers. The documentation on this doesn’t IMHO quite match up with reality, and the “internal_networks” parameter isn’t a white list, but in my experience you’ll have less problems if you list all of your Zimbra servers here.
The following sets of lines tell SpamAssassin to use Pyzor and Razor, and to override the default Pyzor and Razor scores with slightly higher scores.
The last section of lines deal with Originating IP headers in emails. Spamhaus engineering presumes the use of Amavis Policy Banks, which Zimbra does not use out of the box. With Policy Banks, you can apply different Spamassassin processing rules to emails, depending on where they originated. The default Spamhaus config files evaluate all IP addresses listed as the Originating IP in the header, but users who have IMAP clients and do SMTP-Auth from a blocklisted IP at a coffee shop will find Spamhaus (and other tests as described above), will block those emails as spam, just because of the IP address from which the email originated. So, we need first to clear from any Spamassassin/Spamhaus evaluation all originating IP headers, and then explicitly list those headers whose IP addresses should be evaluated — while leaving out the headers (like from IMAP client users) that will likely generate false positives.
So what have we accomplished? We:
- Configured Postfix’s Postscreen and Postfix itself to outright block a huge percentage of junk email in a way that doesn’t tax the Zimbra server, because we do so using nothing more than a raft of DNS lookups.
- Blocked known dangerous attachments and configured Zimbra to let the recipient and System Administrator know that we have done so.
- Adjusted the spam scoring thresholds to values that will block more spam without increasing false positives.
- Enabled Amavis to give us more actionable information by increasing its log level.
- Improved performance by deploying a RAM disk.
- Improved accuracy by:
- Enabling SpamAssassin to update itself.
- Enabling ClamAV to update its virus definitions more frequently.
- Customizing SpamAssassin’s scores to eliminate false positives for Outlook and IMAP client users.
- Customizing SpamAssassin’s scores to improve spam detection overall.
- Spent somewhere between $1 and $4 per mailbox per year to get the benefit of three very good commercial blocklist providers.
- Made our users very happy and reduced frustration for the email administrators!
Zimbra also allows for and supports additional customizations to block spam that the above techniques on their own may not catch, but which may be specific to your environment. One example of this is nested email addresses intended to spoof legitimate email addresses. We wrote about Zimbra’s solution in a blog post late last year. Hopefully this solution makes it into the shipping product in the near term.
If you’d like help with your anti-spam, start the conversation by filling out this form, and we’ll get right back to you!
Hope that helps,
L. Mark Stone
Mission Critical Email
Published originally on 21 March 2019
Updated 19 August 2019
Updated 25 September 2019
Updated 3 February 2020
Updated 9 February 2020
Updated 11 March 2020
Updated 8 April 2020
Updated 12 December 2020
Updated 30 March 2021
P.S. Thanks to Lorenzo Milesi at YetOpen S.r.l. and Sebastián Greco for their helpful suggestions.
The information provided in this blog is intended for informational and educational purposes only. The views expressed herein are those of Mr. Stone personally. The contents of this site are not intended as advice for any purpose and are subject to change without notice. Mission Critical Email makes no warranties of any kind regarding the accuracy or completeness of any information on this site, and we make no representations regarding whether such information is up-to-date or applicable to any particular situation. All copyrights are reserved by Mr. Stone. Any portion of the material on this site may be used for personal or educational purposes provided appropriate attribution is given to Mr. Stone and this blog.