How To Block A Domain From Sending Email From My cPanel Server

We face this problem many times, even we mostly get this kind of issue when a user who is getting hacked a lot and the account is sending out spam emails. In that case, If you want to disable just his account from being able to send mail at all until he can get his script updated or changed. So here’s how we can do it:

First, in root SSH, run these commands:

touch /etc/blockeddomains
echo “” >> /etc/blockeddomains

Please replace with the domain name. Do not replace the “” part as that’s required, only the part with the right domain name.

In WHM > Exim Configuration Editor > Advanced Configuration Editor -> Click on “Add additional configuration setting” -> Add::

domainlist blocked_domains = lsearch;/etc/blockeddomains

Locate the “ROUTERS CONFIGURATION” section, and right below these 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

Put the following lines:


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