Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Unable to add custom exim filter.

Discussion in 'E-mail Discussion' started by Sebasfen132, Nov 29, 2018.

  1. Sebasfen132

    Sebasfen132 Registered

    Joined:
    Nov 29, 2018
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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!
     
  2. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,473
    Likes Received:
    505
    Trophy Points:
    263
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    rpvw likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice