Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Wildcards in account filters

Discussion in 'E-mail Discussion' started by Bob Ulius, Mar 12, 2019.

  1. Bob Ulius

    Bob Ulius Member

    Joined:
    Jun 7, 2015
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Palo Alto, CA
    cPanel Access Level:
    Website Owner
    I'm sure I am not alone when I say SPAM is out of hand. I keep up with it almost daily creating filters, but they are getting out of hand/ For example I have these (that work):

    keto.fat.burn-
    keto-fat-burn
    keto_fat_burn

    Instead of these three, for example, would this work?

    keto?fat?burn?

    Thanks!
     
  2. Bob Ulius

    Bob Ulius Member

    Joined:
    Jun 7, 2015
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Palo Alto, CA
    cPanel Access Level:
    Website Owner
    Likely should have mentioned I use these as Any Header - Contains - Discard Message.
     
  3. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    1,088
    Likes Received:
    442
    Trophy Points:
    113
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    You will probably need to use the 'matches regex' operator rather than 'contains'.

    See How to Configure Mail Filters - cPanel Knowledge Base - cPanel Documentation

    An extremely useful resource to test your regex can be found at regex101.com

    Foe example the regex
    Code:
    keto.fat.burn-*
    looks like it would match the three examples you posted above.

    keto matches the characters keto literally (case sensitive)
    . matches any character (except for line terminators)
    fat matches the characters fat literally (case sensitive)
    . matches any character (except for line terminators)
    burn matches the characters burn literally (case sensitive)
    - matches the character - literally (case sensitive)
    * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #3 rpvw, Mar 12, 2019
    Last edited: Mar 12, 2019
    cPanelLauren likes this.
  4. Bob Ulius

    Bob Ulius Member

    Joined:
    Jun 7, 2015
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Palo Alto, CA
    cPanel Access Level:
    Website Owner
    Thanks. Appreciate your reply.

    Does this search headers only or all of the message? And if I understand what you say, then this:

    keto.fat.burn

    Would match these:

    keto_fat_burn-
    keto-fat-burn-

    And so I would not need either the trailing- or the *. Or am I misunderstanding?
     
  5. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,459
    Likes Received:
    503
    Trophy Points:
    263
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    That depends on what you select for the filter - you'd need to select "Body" "Matches Regex" for this to scan the body of the message.

    He's saying specifically that

    Code:
    keto.fat.burn-*
    
    would match the three terms you listed:

    Code:
    keto.fat.burn-
    keto-fat-burn
    keto_fat_burn
    instead of
    Code:
    keto?fat?burn?
    An explanation of the -* is found at regex101

    Code:
    -* matches the character - literally (case sensitive)
    * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Bob Ulius

    Bob Ulius Member

    Joined:
    Jun 7, 2015
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Palo Alto, CA
    cPanel Access Level:
    Website Owner
    Thanks, but forgive me, I still don't know why I need the "*". I am now testing Any Header Matches Regex keto.fat.burn- and seems to be working as I desire. Am I missing something? Will wait to hear before I add bunches more this way.


    Thanks!
     
    #6 Bob Ulius, Mar 13, 2019
    Last edited: Mar 13, 2019
  7. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,459
    Likes Received:
    503
    Trophy Points:
    263
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    If it's matching as you need it then go with it but the * should allow it to be matched as many times in the body as necessary.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Bob Ulius

    Bob Ulius Member

    Joined:
    Jun 7, 2015
    Messages:
    8
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Palo Alto, CA
    cPanel Access Level:
    Website Owner
    Ahhh, OK. Key word "body". I am searching any header. And even if it were the body, the filter is set to delete the message as soon as the string is found. Hence "*" not needed.

    And this seems to be easier and working better to do the matching regex with "." wildcards rather tha any header "contains" and a separate rule for each possibility of separator.

    Thanks.
     
    cPanelLauren likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice