Skip to main content

Email Filters

Comments

9 comments

  • Novi Singers
    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
  • cPanelMichael
    '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
  • Novi Singers
    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
  • cPanelMichael
    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
  • Novi Singers
    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" endif
    0
  • cPanelMichael
    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
  • Novi Singers
    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
  • cPanelMichael
    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.