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 with the domain that you want to block

touch /etc/blockeddomains
echo "" >> /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:

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

Add the following lines:


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

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