How to use exim variables in filters
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/. 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:
Here is what works the way that I want:
#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:
#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
-
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: /etc/vfilters/ IN_MODIFY echo '%s/\\//g|w|q' | ex - /etc/vfilters/
That removes the '\\' from the file every time cPanel adds it.0 -
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. 0
Please sign in to leave a comment.
Comments
4 comments