Block certain domains on cPanel server from sending emails

Sometimes it is really necessary to block some particular cPanel accounts from sending mails for spamming or whatever reason it may be. So, Is it really possible to block certain domains / accounts from sending out emails in a cPanel server.


Turns out its possible 🙂 But how? Read the rest and find it out 🙂

Exim configuration provides an option to block domains from sending emails. All you have to those domain names into the file “/etc/blockeddomains”.

The steps are explained below:

1. SSH to server as root user.
2. Check the file “/etc/blockeddomains” is existing on the server. If it’s not there create one.

# touch /etc/blockeddomains

3. Add domains in “/etc/blockeddomains” to cut the email sending privilege.

echo “” > /etc/blockeddomains

Or else, open the file “/etc/blockeddomains” with your favorite text editor and add/append the domain into it.

# vi /etc/blockeddomains

The ownership of the file is to be set as root.mail

# chown root.mail /etc/blockeddomains

Set the permission as 640

# chmod 640 /etc/blockeddomains

There are a few more steps to be done to have this working. Once the above steps are done, log into the WHM panel and go to “EXIM Configuration Manager.”
WHM –> Service Configuration –> EXIM Configuration Manager –> Advanced Editor
Search for the string“Add additional configuration setting.”

Add the following entry:

domainlist blocked_domains = lsearch;/etc/blockeddomains

Search for “ROUTERSTART” and add the following entry:


driver = redirect

domains = +blocked_domains


data = :fail: Connection rejected: SPAM source $domain is manually blacklisted.

That’s it.

If any more domain are to be blocked from sending out emails, just add that domain into the file “/etc/blockeddomains” 🙂 🙂

Thats it.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.