The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Email Filters

Discussion in 'E-mail Discussions' started by Novi Singers, Jan 18, 2016.

  1. Novi Singers

    Novi Singers Member

    Joined:
    Dec 20, 2015
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Poland
    cPanel Access Level:
    Root Administrator
    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?
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,449
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Sure, the docs should be of some use:
    Email Filters - Documentation - cPanel Documentation
    (This interface allows you to filter the email for each email account in your domain.)

    Global Filters - Documentation - cPanel Documentation
    (This interface allows you to configure how your server filters all of the email that your domains' email accounts receive.)

    How to Create a Spam Email Filter - cPanel Knowledge Base - cPanel Documentation
    (You can create an email filter that sorts and redirects incoming spam. This is useful if, for example, your hosting provider has not included Apache SpamAssassin™ in your cPanel account.)
     
  3. Novi Singers

    Novi Singers Member

    Joined:
    Dec 20, 2015
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Poland
    cPanel Access Level:
    Root Administrator
    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?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  5. Novi Singers

    Novi Singers Member

    Joined:
    Dec 20, 2015
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Poland
    cPanel Access Level:
    Root Administrator
    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?
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  7. Novi Singers

    Novi Singers Member

    Joined:
    Dec 20, 2015
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Poland
    cPanel Access Level:
    Root Administrator
    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:
    Code:
    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
    
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  9. Novi Singers

    Novi Singers Member

    Joined:
    Dec 20, 2015
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Poland
    cPanel Access Level:
    Root Administrator
    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.
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page