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 the domain name. Also, receive numerous spam emails from domains like qq.com, 126.com, 163.com etc. 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 an 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/exim_blacklist:

[box type=”shadow” align=”” class=”” width=””]vi  /etc/exim_blacklist
Enter a domain name per line in the file and then :wq! and press ENTER to save the file.


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.

  1. In WHM search “EXIM” and click “Exim Configuration Manager”, navigate to the “Advanced Configuration” tab.
  2. 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: Add additional configuration setting
  3. two input box’s will appear, in the first one enter “domainlist exim_blacklist” and in the second one enter “lsearch;/etc/exim_blacklist”.
  4. Scroll down and find the ROUTERS CONFIGURATION section, the first section labelled “Section: PREROUTERS” add the following into the textarea:

[box type=”shadow” align=”” class=”” width=””]
# 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.



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.