Custom Exim Filter Examples
- Written by Vanessa Vasile
- Published in Howto, Mail
- 1 Comment
- Permalink
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
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