I'm trying to create a routing rule, which through a regular expression can block the sending of an email if the recipients (To: Cc: and Bcc :) exceed a certain limit
e.g.
(^To:(.*@.*)+(\n|\r\n|\r)|^Cc:(.*@.*)(\n|\r\n|\r)|^Bcc:(.*@.*)(\n|\r\n|\r)){4,}
MIME-Version: 1.0
Date: Mon, 2 Dec 2019 18:51:05 +0100
Message-ID: <msgID-00000-11111-22222A@mail.gmail.com>
Subject: Test
From: Name <email@example.com>
To: Name <email@example.com>, Name <email@example.com>
Cc: Name <email@example.com>
Bcc: Name <email@example.com>
Content-Type: multipart/related; boundary="00000000000046fe3e0598bc3916"
the problem of this regular expression is that the count of occurrences limited to the fields: To, Cc and Ccn stops at the first value found in each row, so it would only match if I change to {3,}
I can not however count email addresses in a header without limiting to those fields, otherwise I could find several email addresses scattered in the header, like msgId, inside the body or in the signature