Email Filters
I'm trying to use email filters, but have to create them manually. At least I think so as far.
I found several posts regarding manual corrections which other users do and I'm confused how this works, because if we speak ex. about global filters/account level filters, the files are located in /etc/vfilters/domain.tld and /home/username/.cpanel/filter.yaml and /home/username/.cpanel/filter
We have cpanel interface to edit filters.
Could anybody point me to a documentation or explain how all these files are related and what are the ways to change them manually?
-
Sure, the docs should be of some use: (This interface allows you to configure how your server filters all of the email that your domains' email accounts receive.) 0 -
I already went through those documents, but they don't answer my question. Let's stick to Global Filters, because I want to use it and I edit manually, not from the cpanel interface. The are 3 different files. Two of them (/etc/vfilters/domain.tld and /home/username/.cpanel/filter.yaml) are in readable format. So if I edit yaml file, delete cache file, is it enough for the system to recreate cache file and the file in vfilters directory or anything else has to be done? 0 -
't answer my question. Let's stick to Global Filters, because I want to use it and I edit manually, not from the cpanel interface. The are 3 different files. Two of them (/etc/vfilters/domain.tld and /home/username/.cpanel/filter.yaml) are in readable format. So if I edit yaml file, delete cache file, is it enough for the system to recreate cache file and the file in vfilters directory or anything else has to be done?
Hello :) You should utilize our API if you plan to add new filter rules via the command line: UAPI Functions - Email::store_filter - Software Development Kit - cPanel Documentation Otherwise, manual changes to the /etc/vfilters/$domain file are overwritten. Thank you.0 -
Hello Michael, I also found that page you are referring to, but it describes how to create filter, not how to refresh certain files, when it was just modified. Scenario is like that: I have already /home/username/.cpanel/filter.yaml I edited it manually from shell What to do next, to make it working, without using cpanel interface for that? 0 -
You can remove /home/username/.cpanel/filter.cache and manually modify /etc/vfilters/$domain if you prefer not to use the API. However, note the method you are using is unsupported. Thank you. 0 -
Hello Michael, are you saying that it is enough to remove cache file, edit /etc/vfilter/$domain file and Exim will use it? If it is so, I tried it and it didn't work that way. Or it does not work immediately. This is why I ask for comprehensive information. I have several filters to create/modify, so doing it over interface would be more complicated and time consuming. Also syntax requires to use brackets, so it's second reason to do it that way. FYI syntax is like that: if $header_from: contains "root@server.domain.tld" and $header_subject: contains "lfd" and $header_subject: contains "blocked" and ($message_body: contains "DST=ipaddress1" or $message_body: contains "DST=ipaddress2" or $message_body: contains "DST=ipaddress3" or $message_body: contains "string1" or $message_body: contains "string2" or $message_body: contains "string3" or $message_body: contains "string4") then deliver "user@domain.tld" endif0 -
There's no supported method of manually modifying the filter files beyond using the API referenced in my previous response. Thus, while it's possible to manually modify the filter rules, it's not guaranteed to work because it's not a method that we test. Could you elaborate further on why you prefer to avoid using the API function made available? Thank you. 0 -
Hello Michael, I'm elaborating, but have no clue what to do. I included my example filter. This structure is not to implement over cpanel interface. Probably also not to implement over API function. I would prefer (need) to be able edit /etc/vfilter/$domain or /home/username/.cpanel/filter.yaml. Both structures are clear how to modify it. This only missing ingredient is information how to force cpanel to read it after change. Another option is to break this one filter into 4 different filters. But it means multiplying number of filters to create/edit by 4, which is not what I would prefer. There were posts where other users wanted to achieve the same as I want for the same reasons. There is just no information what they did, so I expected that this is the place to share this knowledge. To be honest I expected to get it from cpanel staff as yourself. 0 -
Probably also not to implement over API function.
You should be able to add the filters through our API, which is the supported method. The API function is documented at: UAPI Functions - Email::store_filter - Software Development Kit - cPanel Documentation Thank you.0
Please sign in to leave a comment.
Comments
9 comments