Unable to add custom exim filter.

Sebasfen132

Registered
Nov 29, 2018
1
0
1
MEX
cPanel Access Level
Root Administrator
Hello, im trying to accomplish the same result but with an additional variable. Customer needs only certain email accounts to be able to send/receive mails only from certain domains.

Customer needs:
Email account [email protected]:hosted_in_WHM.com to only be able to send/receive to and from 3 domains aaa.com, bbb.com and ccc.com, all other emails to be descarted with a fail text

Im able to create a custom filter file and get it going, were i can limit the domains or user email, but whenever y add a second variable to the rule i get a MAIN PANIC in Exim arguing "and", or "then" arent being recognized, how can i accomplish this?

---DOESNT WORK
if $header_from: contains "[email protected]:hosted_in_WHM.com"
and
$header_to: does not contain "aaa.com" or "bbb.com" or "ccc.com"
then
fail text "block text"
seen finish
endif

----DOESNT WORK EITHER
if $header_from: contains "[email protected]:hosted_in_WHM.com"
then
if $header_to: does not contain "aaa.com" or "bbb.com" or "ccc.com"
then
fail text "block text"
seen finish
endif

Every time i add a second variable EXIM stops processing ALL server emails with error :

LOG: MAIN PANIC
Error in system filter: unrecognized condition word "then" near line 242 of filter file

Thanks in advance!
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,272
313
Houston
Hi @Sebasfen132


This is because your syntax is incorrect for exim. What I normally do to ensure that it's syntactically correct is create the filter in cPanel>>Mail>>Global Email Filters then once it's finished grab the data written to /etc/vfilters/domain.tld for it and add it to the sysfilter. For example yours:

Code:
if
 $header_from: contains "[email protected]:hosted_in_WHM.com"
 or $header_to: does not contain "aaa.com"
then
 if error_message then save "/dev/null" 660 else fail "Block Text" endif
 finish
endif
 
  • Like
Reactions: rpvw