How to Block E-mail by Domain in cPanel

To block a domain from being able to send or receive mail, use the following steps.

Log into SSH and run the following commands:

Make sure to replace example.com with the domain that you want to block

touch /etc/blockeddomains
echo "example.com" >> /etc/blockeddomains

Log into WHM, then go to Service Configuration > Exim Configuration Editor > Advanced Editor. In the topmostbox add the following:

domainlist blocked_domains = lsearch;/etc/blockeddomains

In the ROUTER CONFIGURATION section after the following lines:

democheck:
driver = redirect
require_files = "+/etc/demouids"
condition = "${if eq {${lookup {$originator_uid} lsearch {/etc/demouids} {$value}}}{}{false}{true}}"
allow_fail
data = :fail: demo accounts are not permitted to relay email

Add the following lines:

reject_domains:

driver = redirect
# RBL Blacklist incoming hosts
domains = blocked_domains
allow_fail
data = :fail: Connection rejected: SPAM source $domain is manually blocked.

Once you have added the lines, hit Save at the bottom.