Custom Exim Filter Examples

3.9/5 - (10 votes)

cPanel allows you to easily create custom Exim filters by simply dropping the rules in /usr/local/cpanel/etc/exim/sysfilter/options/ and running:

/scripts/buildeximconf

service exim restart

Here are a couple useful examples of filters we’ve created for our customers:

Prevent email delivery to certain domains:

if ("$h_to:, $h_cc:" contains "@domain.com")
 or ("$h_to:, $h_cc:" contains "@domain.com")
then
 fail text "Emails to this domain/mail address is temporarily blocked by the Administrator"
seen finish
endif
if not first_delivery
then
 finish
endif

Block email from specific domains:

if
 $header_from: contains "@qq.com"
 or $header_from: contains "zzz.com"
then
 if error_message then save "/dev/null" 660 else fail "Messages from this domain are blocked." endif
endif

Block emails from specific TLDs:

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

1 Comment

  1. Miko Reply

    is there a way to add an exemption?

    if
    $header_from: contains “@qq.com”
    or $header_from: contains “zzz.com”
    but
    $header_from: contains “[email protected]
    then
    if error_message then save “/dev/null” 660 else fail “Messages from this domain are blocked.” endif
    endif

Leave a Reply

Your email address will not be published. Required fields are marked *

Log in