cPanel Exim Filtering to block emails from and to domain TLD (.ru) in the server

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.

10 comments:

  1. Great post! worked like a charm, Thanks for this wonderful post !!!

    ReplyDelete
  2. How to get this working? It seams i'm not so advanced for this...

    ReplyDelete
  3. Thank you! Thank you! Thank you! Thank you! Thank you!

    ReplyDelete
  4. How do I keep from rejecting email from xxxxx@business.rutgers.edu?

    ReplyDelete
  5. Thank you for sharing good ideas.

    ReplyDelete
  6. What if you want to block multiple domains, like "xyz" and "pw" and "link" how is would you write it then?

    ReplyDelete
  7. How to block emails from a particular domain?????????

    ReplyDelete
  8. Be 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
  9. #For blocking all incoming and outgoing emails from a particular domain
    if 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
    ******************************************************************************************

    ReplyDelete
  10. Change contains to ends.

    Contains means it will pull any string within the domain name itself, you just want the end of it which will always be the tld.

    ReplyDelete