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!

How to use exim variables in filters

Discussion in 'E-mail Discussion' started by mcowper, May 3, 2019.

Tags:
  1. mcowper

    mcowper Registered

    Joined:
    Mar 12, 2013
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    DataCenter Provider
    I'm trying to create an account-level filter that will match any email where the from address and the to address are the same. My approach was to check if the from header matched the to header using the exim variable $header_to. I created this through the web interface and tested it and it didn't work. After some experimenting and research I found that the filter that is created that way is actually in /etc/vfilters/<domain>. Looking at that file I found that the '$' is escaped by '\\', which is not what I want. I can modify that file by removing the '\\' and the filter works as I expect, however that file will be overwritten. Is there a way to do it so that the '$' is not escaped?

    Here is what is put in the file by the cPanel interface:
    Code:
    #Test
    if
     $header_from: contains "\\$header_to"
    then
     if error_message then save "/dev/null" 660 else fail "Don't send email to myself" endif
    endif
    
    Here is what works the way that I want:
    Code:
    #Test
    if
     $header_from: contains "$header_to"
    then
     if error_message then save "/dev/null" 660 else fail "Don't send email to myself" endif
    endif
    
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,325
    Likes Received:
    2,157
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @mcowper,

    Can you use our Defects link so we can take a closer look and verify if this is a defect with the way filter rules are added? You can post the ticket number here once it's open and we'll link this thread to it.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. mcowper

    mcowper Registered

    Joined:
    Mar 12, 2013
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    DataCenter Provider
    I have done so. The number is 12233891.

    Thank you.
     
    cPanelMichael likes this.
  4. mcowper

    mcowper Registered

    Joined:
    Mar 12, 2013
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    DataCenter Provider
    I understand that there is no way around this currently using cPanel. I will be putting in a feature request. In the meantime this is the solution that I came up with in case anybody else runs into this.

    I installed incron on the server. It is a daemon similar to cron that runs commands on filesystem events rather than time events. I then created an incrontab entry for the user that contained the following line:
    Code:
    /etc/vfilters/<domain> IN_MODIFY echo '%s/\\//g|w|q' | ex - /etc/vfilters/<domain>
    That removes the '\\' from the file every time cPanel adds it.
     
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,325
    Likes Received:
    2,157
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @mcowper,

    Thank you for submitting the ticket and sharing the workaround. Let me the feature request URL once it's opened and I'll link it to the internal case noted below.

    Internal case CPANEL-27301 was opened to request an improvement to the filter creation UI in cPanel so that Exim variables are supported as values.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
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