Regular Expression for end character not working

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
milis75
New user
New user
Posts: 12
Joined: 2020-09-17 10:11

Regular Expression for end character not working

Post by milis75 » 2020-09-17 12:44

Hi All,

I use Regular Expression .+?\.mx to filter email address with last character .mx
in test rule is match
but not working if any message from abcd@efgh.mx

&

how to forward & delete email from VBscript because Criteria logic cannot combine AND and OR

Thx guys :D

User avatar
jimimaseye
Moderator
Moderator
Posts: 8917
Joined: 2011-09-08 17:48

Re: Regular Expression for end character not working

Post by jimimaseye » 2020-09-17 14:07

.+?\.mx

works for me.

Have you actually tried it?
Screenshot 2020-09-17 130626.png
Also read this for tips and explanations: https://www.hmailserver.com/forum/viewt ... 21&t=29179
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
katip
Senior user
Senior user
Posts: 812
Joined: 2006-12-22 07:58
Location: Istanbul

Re: Regular Expression for end character not working

Post by katip » 2020-09-17 15:11

have you tried custom header field From?
or try custom header X-Envelope-From
Katip
--
HMS 5.7.0 x64, MariaDB 10.4.10 x64, SA 3.4.2, ClamAV 0.101.2 + SaneS

User avatar
SorenR
Senior user
Senior user
Posts: 4197
Joined: 2006-08-21 15:38
Location: Denmark

Re: Regular Expression for end character not working

Post by SorenR » 2020-09-17 19:32

katip wrote:
2020-09-17 15:11
have you tried custom header field From?
or try custom header X-Envelope-From
"From:" syntax is "name <user@domain.tld>"

"From:" can be faked using any mail client

"X-Envelope-From:" an identified user on the sending server sending the email. Need modified MTA to fake.
SørenR.

Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.

milis75
New user
New user
Posts: 12
Joined: 2020-09-17 10:11

Re: Regular Expression for end character not working

Post by milis75 » 2020-09-18 02:36

jimimaseye wrote:
2020-09-17 14:07
.+?\.mx

works for me.

Have you actually tried it?

Screenshot 2020-09-17 130626.png

Also read this for tips and explanations: https://www.hmailserver.com/forum/viewt ... 21&t=29179
of course I have tried, Sir ... I told before in the test is match

Thx for Tips Reg Exp 8)
Last edited by milis75 on 2020-09-18 02:43, edited 1 time in total.

milis75
New user
New user
Posts: 12
Joined: 2020-09-17 10:11

Re: Regular Expression for end character not working

Post by milis75 » 2020-09-18 02:40

katip wrote:
2020-09-17 15:11
have you tried custom header field From?
or try custom header X-Envelope-From
Not yet
I will try to other Criteria ,...
but actually I want Criteria "From"

milis75
New user
New user
Posts: 12
Joined: 2020-09-17 10:11

Re: Regular Expression for end character not working

Post by milis75 » 2020-09-18 03:21

Mr SorenR & Katip

It Turn out that from "abcd@efgh.MX" it must be written in Regular Expression ".MX>"
not just ".MX" ... So I write less > character become Regular Expression not working

Thank you All :wink:

User avatar
katip
Senior user
Senior user
Posts: 812
Joined: 2006-12-22 07:58
Location: Istanbul

Re: Regular Expression for end character not working

Post by katip » 2020-09-18 08:12

SorenR wrote:
2020-09-17 19:32
katip wrote:
2020-09-17 15:11
have you tried custom header field From?
or try custom header X-Envelope-From
"From:" syntax is "name <user@domain.tld>"

"From:" can be faked using any mail client

"X-Envelope-From:" an identified user on the sending server sending the email. Need modified MTA to fake.
indeed, i intentionally didn't considered brackets (<>) as they may or not appear in From. i'm not sure if they MUST or not as per RFC though, anyway we receive such mails.
OTOH, from one recent spam i received:

Code: Select all

From: "Disfruta <info@dis-fruta.mx>" <j.martinez@stanleyadams.com.de>
it's a perfect From, but that regex would fail.
hence, a better regex could be

Code: Select all

.+?\.mx(|>)$
Katip
--
HMS 5.7.0 x64, MariaDB 10.4.10 x64, SA 3.4.2, ClamAV 0.101.2 + SaneS

palinka
Senior user
Senior user
Posts: 2475
Joined: 2017-09-12 17:57

Re: Regular Expression for end character not working

Post by palinka » 2020-09-18 20:51

katip wrote:
2020-09-18 08:12
SorenR wrote:
2020-09-17 19:32
katip wrote:
2020-09-17 15:11
have you tried custom header field From?
or try custom header X-Envelope-From
"From:" syntax is "name <user@domain.tld>"

"From:" can be faked using any mail client

"X-Envelope-From:" an identified user on the sending server sending the email. Need modified MTA to fake.
indeed, i intentionally didn't considered brackets (<>) as they may or not appear in From. i'm not sure if they MUST or not as per RFC though, anyway we receive such mails.
OTOH, from one recent spam i received:

Code: Select all

From: "Disfruta <info@dis-fruta.mx>" <j.martinez@stanleyadams.com.de>
it's a perfect From, but that regex would fail.
hence, a better regex could be

Code: Select all

.+?\.mx(|>)$
Maybe a small improvement here:

.*\.mx(>|"){0,2}$


Will catch:

Code: Select all

From: "Disfruta <info@dis-fruta.mx>" <j.martinez@stanleyadams.com.mx>
And:

Code: Select all

From: "Disfruta <info@dis-fruta.mx>"
I'm just circling back to Soren's statement:
"From:" syntax is "name <user@domain.tld>"
Here the string ends with both > and "

I don't even know if that happens in real life. :D

User avatar
SorenR
Senior user
Senior user
Posts: 4197
Joined: 2006-08-21 15:38
Location: Denmark

Re: Regular Expression for end character not working

Post by SorenR » 2020-09-19 00:28

palinka wrote:
2020-09-18 20:51

I'm just circling back to Soren's statement:
"From:" syntax is "name <user@domain.tld>"
Here the string ends with both > and "

I don't even know if that happens in real life. :D
Okay... I was quoting a string... Real life examples that I check for (script wise) are:

<taz@acme.inc>
Devil <taz@acme.inc>
"Tasmanian Devil" <taz@acme.inc>
SørenR.

Algorithm (noun.)
Word used by programmers when they do not want to explain what they did.

palinka
Senior user
Senior user
Posts: 2475
Joined: 2017-09-12 17:57

Re: Regular Expression for end character not working

Post by palinka » 2020-09-19 03:11

👍

Post Reply