cPanel comes stock with a number of ACLs and tuneables to help reduce the amount of unwanted email into your server. At present, there are not a lot of controls on the Exim side that allow for blocking specific email addresses or servers. While you can easily use the integrated SpamAssassin controls on a per-cPanel account basis, it’s generally less resource-intensive to handle these blocks at SMTP time.
cPanel’s implementation of Exim is set to automatically load filters from an include directory. This directory is located here:
Any files you drop in here will be included into the Exim filter. First, create a file in this folder. You can name it anything you want, but we’ll call ours inbound_tld_block:
In this file, add the following filter, replacing .tld with the actual TLD you want to block:
and ("$h_to:, $h_cc:" contains ".tld")
or ("$h_from:" contains ".tld")
Now go into WHM -> Exim Configuration Manager -> Basic Editor -> Filters, and you should see the new filter listed:
** Custom Filter: inbound_tld_block
If it’s not already enabled, enable it here and then save.
To disable the filter, you can set it to “Off” in the same location in WHM and hit Save again.