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.

Server-wide per-account email filter?

Discussion in 'E-mail Discussions' started by ChrisTNM, Jul 23, 2014.

  1. ChrisTNM

    ChrisTNM Member

    Joined:
    Sep 24, 2013
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Does anyone know if this is possible? I would like to deliver mail with specific keywords in the subject link to the "Junk" folder relative to the account. So if an email with the keyword "spam" in the subject is sent to bob@somewebsite.com then it is automatically filtered into the INBOX/Junk folder. I can setup a filter to do this on every account manually, but I'm curious to know if this can be done at a server level. Any thoughts?

    I did some searching and I am not the first to pose this question, but I do not want to simply nullify the message and I'm not sure how to sort it to be relative to the account it's being delivered to.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,830
    Likes Received:
    672
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. ChrisTNM

    ChrisTNM Member

    Joined:
    Sep 24, 2013
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thanks! This is the direction I needed to get started but it only answers half my question.
    Let's say I do this:

    Code:
    # Spam Subject
    if
     $header_subject: contains "{Spam"
    then
      # Save to "junk" folder?
      save "/dev/null" 660
    endif
    Instead of nul-routing the email, how can I save it to the folder relevant to the account it's being delivered to? I still want to deliver the email, but in this case I want to deliver it to a specific folder.

    Is this possible?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,830
    Likes Received:
    672
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    One way to learn how to write filter rules is to create an account level filter in cPanel similar to what you want to do in a system filter, and then view the rule directly in:

    /etc/vfilters/$domain.com

    This will help show you how to write a filter rule.

    Thank you.
     
  5. ChrisTNM

    ChrisTNM Member

    Joined:
    Sep 24, 2013
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Alright, thank you. :)
     
  6. ChrisTNM

    ChrisTNM Member

    Joined:
    Sep 24, 2013
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Okay, so if I create a account level filter, then I get something like this:

    Code:
    #{Spam?}
    if
    $header_subject: contains "{Spam?}"
    then
    save "$home/mail/domain.com/user/.Junk/" 660
    endif
    
    How can I get the "domain.com/user" part dynamically so it goes into the correct users folder? This is the part I'm stuck on. Any assistance would really be appreciated. Is this even possible?

    Is there documentation on this somewhere?

    Edit:
    Found this:
    Code:
     save "$home/mail/$domain/$local_part/.Junk/" 660
    
    Source: http://www.exim.org/exim-html-current/doc/html/spec_html/filter_ch-exim_filter_files.html#SEC19
    Not sure if it's correct.
     
    #6 ChrisTNM, Sep 1, 2015
    Last edited: Sep 1, 2015
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,830
    Likes Received:
    672
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  8. ChrisTNM

    ChrisTNM Member

    Joined:
    Sep 24, 2013
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Actually, no.. it didn't work. It apparently didn't do anything after I enabled the rule from WHM in the exim config. I just tried sending an email with "{Spam?}" in the subject and it went right to my inbox.

    [​IMG]
     
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

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

Share This Page