Email filter matching a negative regex

Valetia

Well-Known Member
Jun 20, 2002
214
10
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,911
2,234
363
Hello,

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

Thank you.
 

Valetia

Well-Known Member
Jun 20, 2002
214
10
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)"
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,911
2,234
363
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.
 

Valetia

Well-Known Member
Jun 20, 2002
214
10
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? :)
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,911
2,234
363
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.
 

Valetia

Well-Known Member
Jun 20, 2002
214
10
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,911
2,234
363
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.