How to block accounts from sending emails – cPanel/WHM

Is it possible to block certain domains/accounts on my server for sending emails?

Yeah, it’s possible to block certain domains from sending emails from server. There is an option in Exim configuration on your cPanel server to block domains from sending emails. This can be done by adding those domains into “/etc/blockeddomains” this configuration file.

Here I’m going to explain the steps to block accounts from sending emails. You must have a server with root access to do so. The steps are explained below:

1. SSH to server as root.
2. Check the file “/etc/blockeddomains” is existing on the server. If it’s not there create one.
3. Add domains in “/etc/blockeddomains” to cut the email sending privilege.

You can use the following commands:

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

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

# vi /etc/blockeddomains
thedomain.com
~
~

4. Set correct ownership to “/etc/blockeddomains.”

# chown root.mail /etc/blockeddomains

5. Set correct permission.

# chmod 640 /etc/blockeddomains

6. Then log into the WHM panel and go to “EXIM Configuration Manager.”

WHM –> Service Configuration –> EXIM Configuration Manager –> Advanced Editor

Search for “Add additional configuration setting.” This can be located one by forth of the way of scroll down 🙂

block1

Add the following entry:

domainlist blocked_domains = lsearch;/etc/blockeddomains

block2

7. Search for “ROUTERSTART” and add the following entry:

reject_domains:

driver = redirect
domains = +blocked_domains
allow_fail
data = :fail: Connection rejected: SPAM source $domain is manually blacklisted.

This should be look like:

block3

Yeah, that’s it!! Next time if you want to block another domain from sending emails, just add that domain into “/etc/blockeddomains” this file, that’s it!!

Let me know if you have any questions!

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

Leave a Reply

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