Sometimes we want to block specific domains from sending email to any of our users. If you followed the instructions to prevent nested address spoofing, the mechanism to perform system-wide sender domain blocking is already in place. If you haven’t yet deployed nested address spoofing, please go ahead and do so now, as doing so will block a large number of phishing attack emails. Come back here after you are done. OK?
Let’s say you keep getting blasted with promotions for sales lead generation or other unwanted marketing services repeatedly from sales people at the bestsalesleadgenerators.com domain. Probably some of your staff have already added the domain or one of the senders to their email Filters, but filter processing is very expensive from a resource standpoint. Blocking these senders at the front door is much more efficient.
To do so, all we need to do is add those domains to the /opt/zimbra/conf/sender_pcre file on our Zimbra MTA, understanding that this file has some syntax requirements (documented here).
Here’s what the file looks like after adding that problematic domain we want to block:
/@.*@/ reject /bestsalesleadgenerators\.com/ reject
After you edit the file, we need to let Postfix know about it, so just run as the zimbra user:
You are done!
If you want to block additional domains, just add them, each on a new line. Please note that blocking a specific domain will also block all subdomains!
You can see the results of your good efforts in the Daily Mail Report in the “Sender address rejected” section:
Sender address rejected: Access denied (total: 278) 13 firstname.lastname@example.org 12 email@example.com 2 firstname.lastname@example.org 1 email@example.com 1 firstname.lastname@example.org 1 email@example.com 1 firstname.lastname@example.org 1 email@example.com 1 firstname.lastname@example.org 1 email@example.com 1 firstname.lastname@example.org 1 email@example.com 1 firstname.lastname@example.org 1 email@example.com <snip>
Hope that helps,
L. Mark Stone
Mission Critical Email LLC
26 May 2022; Updated 11 June 2022 with Daily Mail Report data
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.