Match Field - Multi Line Regex for To Field

Joe Botha

Well-Known Member
Apr 11, 2019
30
1
48
Cape Town
www.atomicaccess.co.za
Hi

Trying to use a What Object with Match Field regex. I believe some mail clients sent the To field in more than one line.

It seems Perl has a /s modifier which lets lets . match newline - but I can't seem to use /s in the pmg config interface (Test String fails).

Do you have advice for writing a regex that would match things in the To field of an email which spans multiple lines?
 
Could you share such an email (the complete mail with headers in a code-block)
maybe we can find something fitting.
 
on a quick test this seems to work fine here:
Code:
From: sender <sender@sender.domain.example>
To: receiver@domain.example, support@test1.domain.example
 support@test2.domain.example
Bcc: 
Subject: test 
[code]

gets matched by To=(support@.*){2,}

What would not get matched is 2 'To' headers each with one containing one 'support@' - afaict
 
Hi, side note: would be great to also stop people from sending:

To: support@foo
Cc: support@bar
That's not really possible with the current rulesystem - it matches certain headers with regex - there is no possiblity to join multiple different headers together and match on those.
 
  • Like
Reactions: Joe Botha
Hi, is the regex logic in Perl?

Perl seems to support this with /s

Maybe this should be the default behaviour for match-field setting.
No - not quite - this is how the headers are extracted from the mail - the for loop I linked iterates over all occurrences of a To header individually so the /s switch would not help - and if it's only one header with multiple lines - those are joined together on extraction so /s is not needed.

Thanks for the enhancement request.