Block Email from a Country or Domain in cPanel

Last modified: July 31, 2020
You are here:
Estimated reading time: 3 min

Email security is the collective measures that we can use to secure the content and access of an email service or account. cPanel has released a new feature to block email from a country or domain. This feature helps you to block emails server-wide or on a per-user basis. The email block feature of cPanel helps to avoid spamming from a particular country or domain to your email account. If an unsolicited message or spam gets sent using a messaging system, then it is known as spamming. If you suspect that the spamming of your email account is from a particular domain or country, then you can always go for the email block feature in cPanel to block all the emails from that particular country or domain. In this knowledgebase, you learn how to block email from a country or domain in cPanel.

 

Configure Mail Filters

You can configure email filters to determine how to handle your email messages. In cPanel, you can configure both global email filters and also user-level filters.

 

Global Email Filters: You can use the global email filters interface to set rules for all the cPanel account’s email addresses. This can be set from cPanel under the path: cPanel >> Home >> Email >> Global Email Filters.

 

Email Filters: You can use the Email Filters interface to set rules for specific email addresses on the cPanel account. This can be set from cPanel under the path: cPanel >> Home >> Email >> Email Filters.

 

Configure the Apache SpamAssassin Report_Safe Option

If a mail fails the spam test, then the Apache SpamAssassin can alert the same if you have set the Apache SpamAssassin Report_Safe option. This can be configured under the ‘/etc/mail/spamassassin/local.cf’ Global configuration file. You can follow the below two steps to configure the Report_Safe option.

 

1) Enable the Old-Style Spam System Setting

The old-style spam system setting is not available in cPanel & WHM version 54. If we enable this setting in the cPanel & WHM version 11.52 and earlier, Exim cannot override any changes to the global configuration file.

1) Log in to WHM as the root user and navigate to ‘Service Configuration’.

2) Navigate to WHM’s ‘Exim Configuration Manager’ interface and select the ‘Apache SpamAssassin’ options tab.

3) Select ‘On’ for the Old-Style Spam System Setting.

4) Click ‘Save’.

 

2) Edit the Global Apache SpamAssassin Configuration file

To enable the Apache SpamAssassin, we can modify the ‘Report_Safe’ value in the ‘/etc/mail/spamassassin/local.cf’ File. We can add the below values as per the requirement:

Value Description
0 Show the SPAM rules in the email header, and it leaves the message body intact.
1 Add the following attachments:1) Suspected spam email

2) Document with detailed spam rule offense

2 The email body includes the spam rule offense text, and add the following attachments:1) Suspected spam email

2) Document with detailed spam rule offense

 

 

How to Block Emails by Country or Domain

The new release in cPanel has added a new feature to block emails by country or domain. You can use the below interfaces to block email messages:

 

1) Filter Incoming Emails by Country

1) Log in to WHM as the root user and navigate to the ‘Email’ section.

2) Select ‘Filter Incoming Emails by Country’ option.

This interface allows you to filter your incoming emails by region or country. By using this interface, you can allow only mail from a single country, so that it blocks the emails from other countries.

To block the emails from a Country, you can disable the Allowed toggle for that country under the Countries table. To allow or block every country, you can follow the below steps:

1) Select the ‘Select All’ checkbox at the top left of the interface.

2) You can click ‘Allow Selected’ to allow all the selected countries.

3) Alternatively, you can click ‘Block Selected’ to block them.

 

2) Filter Incoming Emails by Domain

1) Log in to WHM as the root user and navigate to the ‘Email’ section.

2) Select the ‘Filter Incoming Emails by Domain’ option.

By using this interface, you can block emails from a particular domain. If you specify the domain in this interface, then your server rejects email messages when the ‘From’ address matches a blocked domain. This feature is useful to block all email messages from a domain that sends only spam.

You can block a domain by performing the below steps:

1) To block a domain, you can add its detail in the ‘Blocked Domains’ text box. For blocking multiple domains, you can use a new line for each domain.

2) Click ‘Save’.

To block all the emails from subdomains of a given domain, you can prefix the domain name with an asterisk (*) character. This character is a wildcard so that it rejects any mails from the subdomains also. For example, if you give ‘*.test.com’ domain in the ‘Blocked Domains’ text box. Then your server rejects any email message from any subdomain of the test.com domain like abc.test.com, xyz.test.com, etc.

 

Was this article helpful?
Dislike 0
Views: 6