How to block domain from sending Email in cpanel

If you have account that doesn’t use Emails and gets haked a lot, you can just disable that domain from sending emails and that will stop spam from your server. The way to do it in Cpanel is described here..

You have to Log in to server over SSH and type this:

touch /etc/blockeddomains
echo “domain.com” >> /etc/blockeddomains

“domain.com” is the domain you like to block so you have to set change it to your domain. After that you have to set in Exim config some directives:

In WHM > Exim Configuration Editor > Advanced Editor, put the following in the topmost box:
domainlist blocked_domains = lsearch;/etc/blockeddomains

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

Put 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 blacklisted.

And that’s it..