How Do I Block One Domain From Sending Email using SMTP From My Server?

13th Apr 2024 | category: Emails | Hits: 1179 How Do I Block One Domain From Sending Email using SMTP From My Server?
STEP 1

Login into your server,
# touch /etc/blockeddomains

# echo "domain.com" >> /etc/blockeddomains


Please replace domain.com with the domain name. Do not replace the "" part as that's required, only the domain.com part with the right domain name.

STEP 2

In WHM > Exim Configuration Manager > Advanced Editor, put the following line of code below in the topmost box:

domainlist blocked_domains = lsearch;/etc/blockeddomains

 Exim Configuration Manager > Advanced Editor Exim Configuration Manager > Advanced Editor
STEP 3

Still under -- WHM > Exim Configuration Manager > Advanced Editor
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.


NOTE: on new versions of Cpanel - put that code in Section: ROUTERSTART.


Save & Good to go.