Block Emails By Domain Extension

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,298
1,279
313
Houston
Hello,


The interface for this details the syntax as follows:

Filter Incoming Emails by Domain
This interface allows you to manage a list of domains that may not send mail to your server. The system will reject any messages that it receives whose “From” address matches one of this list’s domains.
You can reject all subdomains of a given domain by prefixing the name with an asterisk (*). For example, “*.example.com” will cause this server to reject all messages sent from any subdomain of “example.com”.
This interface accepts IDNs.
They use a subdomain as the example but you could use a wildcard to block all from that tld. For example I blocked *.dk and asked my friend with a .dk domain to send me an email:
Code:
2019-10-30 15:12:56 H=host.name.tld [<IPADDRESS>]:26888 X=TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256 CV=no F=<[email protected]> rejected RCPT <[email protected]>: Sender domain is banned
The bounce he received looked as follows:

Code:
Final-Recipient: rfc822; [email protected]
Original-Recipient: rfc822;[email protected]
Action: failed
Status: 5.0.0
Remote-MTA: dns; mydomain.us
Diagnostic-Code: smtp; 550 Your host is not allowed to connect to this server.
Thanks!
 

CharlesGLondon

Active Member
Jan 30, 2019
27
3
3
London
cPanel Access Level
Website Owner
Thanks for reply.
I've one more question. How do we block all domains which have only numbers in domain names.
E.g. 1234.com 2319.com etc..
Does this block support regex?

If it's not possible to do it from here, then is there any other way to do it?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,298
1,279
313
Houston

CharlesGLondon

Active Member
Jan 30, 2019
27
3
3
London
cPanel Access Level
Website Owner
I already have this filter see one below. Does anyone know how to add regex to block all domains with all numbers in it?

Code:
if first_delivery
and ("$h_to:, $h_cc:" contains ".icu")
or ("$h_from:" contains ".icu")
then
seen finish
endif