Updated 15/09/2017
If like me you have a serious problem with recurring SPAM by companies who just keep emailing you asking you if you have read their previous email and that the "great proposal" they made before is still available; then you may be looking to block email addresses by domain name. This sort of SPAM is so ANNOYING because they are just insistent on getting you to reply, but you simply want them to go away!! Well now you can force them to go away forever, with a full domain block. This obviously only works for companies who are sending email from their own domain names instead of generic gmail or hotmail accounts, but its very effective as NO email from blocked domains will ever be delivered to any account on your server, they will not even get as far as being processed and will simply be ignored as soon as they request to deliver an email. I found a guide online but it was really messy and confusing so I thought I would create my own guide detailing how to block emails in WHM / Exim by their domain name. Follow my step by step guide below.
Step 1: Create Exim blacklist file
You will need ROOT SSH access to your server, run the following command to create and open a new file in /etc/eximblacklist:
nano /etc/eximblacklistEnter a domain name per line in the file and then CTRL + O and press ENTER to save the file.
blockthisdomain.com alsoblockthis.co.uk finallythistoo.org
Note: You can add more domains by following the same command and adding more domains on new lines, then restart Exim (see step 3).
Step 2: Add blacklist to Exim config
You will now need to configure EXIM so that it will pick up your blacklist and process any emails against the list, ignoring any that match the domain name.
- In WHM search "EXIM" and click "Exim Configuration Manager", navigate to the "Advanced Configuration" tab.
- Scroll down and find the BIG BLUE button labelled "Add additional configuration setting" and click the button, the button should look like the image below:
- two input box's will appear, in the first one enter "domainlist exim_blacklist" and in the second one enter "lsearch;/etc/exim_blacklist".
- Scroll down and find the ROUTERS CONFIGURATION section, the first section labelled "Section: PREROUTERS" add the following into the textarea:
# Inserted to block domains access # Local from blacklist: /etc/exim_blacklist reject_domains: driver = redirect # RBL Blacklist incoming hosts domains = +exim_blacklist allow_fail data = :fail: Connection rejected: $domain is manually blacklisted.
Step 3: Save Exim & Restart Exim
Scroll to the bottom and click save which will save all the settings and restart Exim. TIP: If you edit your blacklist file in future simply search WHM for Exim and click on "Mail Server (Exim)" and click restart.
Conclusion...
So there you have it, pretty easy to setup... Emails that match the domains in this list will just be silently ignored, the sender will not know, you will not know and you can continue your work in peace. Hope this helps.






Hello. Thank you for the article. I run a LAMP server with WHM/Cpanel 68.0.28. I set the domain block in my EXIM as above and rebot the server. It will result that I am not able to send emails, error '421 Unexpected failure, please try later'. Please any advice is welcome! :-)
Great tutorial!
I think point 3 and 4 have an error.
filename should be eximblacklist, not exim_blacklist :)