Exim Filtering to block emails from and to domain TLD (.ru) in the server
-------------------------------------------------------------------------
] ~ >>cp -pr /etc/cpanel_exim_system_filter /usr/local/cpanel/etc/exim/sysfilter/options/
] ~ >>vi /usr/local/cpanel/etc/exim/sysfilter/options/cpanel_exim_system_filter
Add following line to file /usr/local/cpanel/etc/exim/sysfilter/options/cpanel_exim_system_filter,
=======================================
#For blocking all incoming and outgoing russian emails
if first_delivery
and ("$h_to:, $h_cc:" contains ".ru")
or ("$h_from:" contains ".ru")
then
seen finish
endif
=======================================
Give custom exim filter file location in WHM,
WHM Home »Service Configuration »Exim Configuration Manager
System Filter File ---> /usr/local/cpanel/etc/exim/sysfilter/options/cpanel_exim_system_filter
Restart Exim service.
-------------------------------------------------------------------------
] ~ >>cp -pr /etc/cpanel_exim_system_filter /usr/local/cpanel/etc/exim/sysfilter/options/
] ~ >>vi /usr/local/cpanel/etc/exim/sysfilter/options/cpanel_exim_system_filter
Add following line to file /usr/local/cpanel/etc/exim/sysfilter/options/cpanel_exim_system_filter,
=======================================
#For blocking all incoming and outgoing russian emails
if first_delivery
and ("$h_to:, $h_cc:" contains ".ru")
or ("$h_from:" contains ".ru")
then
seen finish
endif
=======================================
Give custom exim filter file location in WHM,
WHM Home »Service Configuration »Exim Configuration Manager
System Filter File ---> /usr/local/cpanel/etc/exim/sysfilter/options/cpanel_exim_system_filter
Restart Exim service.
Great post! worked like a charm, Thanks for this wonderful post !!!
ReplyDeleteHow to get this working? It seams i'm not so advanced for this...
ReplyDeleteThank you! Thank you! Thank you! Thank you! Thank you!
ReplyDeleteHow do I keep from rejecting email from xxxxx@business.rutgers.edu?
ReplyDeleteThank you for sharing good ideas.
ReplyDeleteWhat if you want to block multiple domains, like "xyz" and "pw" and "link" how is would you write it then?
ReplyDeleteHow to block emails from a particular domain?????????
ReplyDeleteBe careful with this code because I had a complaint from a customer because it's also blocking let's say this non Russian address: babs.ruiz-AT-domain.com (because it contains the .ru)
ReplyDelete#For blocking all incoming and outgoing emails from a particular domain
ReplyDeleteif first_delivery
and ("$h_to:, $h_cc:" contains "yourdomain.com")
or ("$h_from:" contains "yourdomain.com")
then
seen finish
endif
******************************************************************************************
#For blocking all incoming and outgoing emails from a multiple domains
if first_delivery
and ("$h_to:, $h_cc:" contains "yourdomain1.com")
or ("$h_from:" contains "yourdomain1.com")
then
seen finish
endif
if first_delivery
and ("$h_to:, $h_cc:" contains "yourdomain2.com")
or ("$h_from:" contains "yourdomain2.com")
then
seen finish
endif
if first_delivery
and ("$h_to:, $h_cc:" contains "yourdomain3.com")
or ("$h_from:" contains "yourdomain3.com")
then
seen finish
endif
******************************************************************************************
Change contains to ends.
ReplyDeleteContains means it will pull any string within the domain name itself, you just want the end of it which will always be the tld.