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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Email filter matching a negative regex

Discussion in 'E-mail Discussions' started by Valetia, Aug 27, 2017.

Tags:
  1. Valetia

    Valetia Well-Known Member

    Joined:
    Jun 20, 2002
    Messages:
    213
    Likes Received:
    1
    Trophy Points:
    168
    cPanel Access Level:
    Root Administrator
    How does one create an email filter in cPanel that matches a negative regex?

    Entering usual negative regex format (?!string) in the Email Filters section in cPanel doesn’t seem to make a difference.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,165
    Likes Received:
    1,372
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you let us know the specific filter rule you are adding?

    Thank you.
     
  3. Valetia

    Valetia Well-Known Member

    Joined:
    Jun 20, 2002
    Messages:
    213
    Likes Received:
    1
    Trophy Points:
    168
    cPanel Access Level:
    Root Administrator
    This (positive regex) triggers when the header exists:

    "Any Header" "matches regex" "tsid: 123"

    but the following (negative regex) doesn’t trigger when the header is missing:

    "Any Header" "matches regex" "(?!tsid: 123)"
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,165
    Likes Received:
    1,372
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Exim provides documentation on the use of regular expressions at:

    8. Regular expressions

    You will likely receive more user-feedback on custom regular expression rules (such as the negation of a value like you described) on the Exim-user's mailing list:

    Exim-users

    Thank you.
     
  5. Valetia

    Valetia Well-Known Member

    Joined:
    Jun 20, 2002
    Messages:
    213
    Likes Received:
    1
    Trophy Points:
    168
    cPanel Access Level:
    Root Administrator
    Thanks Michael!

    Just realized that the "does not match" option works with regex too, so the issue is now resolved.

    I hadn’t thought that regex would work with it, since the "matches regex" option in the dropdown menu contains the word "regex", while the "does not match" option doesn’t.

    Should this be filed as a (very minor) bug report? :)
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,165
    Likes Received:
    1,372
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    One issue with changing "does not match" to "does not match regex" is that it could potentially confuse users into thinking that only a regular expression can be used with that rule. Instead, I recommend opening a feature request for the addition of a "does not match regex" option in the filter interface:

    Submit A Feature Request

    Thank you.
     
  7. Valetia

    Valetia Well-Known Member

    Joined:
    Jun 20, 2002
    Messages:
    213
    Likes Received:
    1
    Trophy Points:
    168
    cPanel Access Level:
    Root Administrator
    The "matches regex" option in the dropdown actually translates into just "matches" in the actual Exim filter itself. Nevertheless, Exim does seem to primarily expect a regex string for that option.

    The option "does not match" in the dropdown translates into the same ("does not match") in the actual Exim filter. It appears to be very similar in nature, in that Exim primarily expects it too to contain a regex string.

    In fact, the current label "does not match" in the dropdown could likely be causing greater confusion by leaving out the word "regex" because:

    (a) The "matches regex" option in the dropdown includes the word "regex" to clarify its intended usage, but the companion option "does not match" doesn’t, causing inconsistency.

    (b) The "equals" option in the dropdown translates into "is" in the actual Exim filter. However, its companion option "does not equal" (translating into "is not" in the Exim filter) appears to be completely missing from the dropdown. This leads some users (including myself) to mistake "does not match" for "does not equal".

    With this in mind, let me know if you’d still like for me to open the specific feature request that you’ve suggested, or if you’d like different action to be taken.
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,165
    Likes Received:
    1,372
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    A feature request is still a good idea for this particular topic as the existing filter operators in the drop-down menu have shown "does not match" for quite sometime. Feel free to post the feature request URL here once it's opened so others can vote for the request as they come across this thread.

    Thank you.
     
Loading...

Share This Page