-2

I know that there seems to be no perfect regex to match even one email address, but I'm trying to catch outgoing emails that are sent with multiple TO: header recipients, and the only option I have is to apply a regex to match the text of the full headers. The idea is that if there is only 1 email in the TO: header, the email should NOT match the regex, and it will be sent. But if there is more than email in the TO: header, it should match the regex and then I can reject the message.

iopener
  • 187
  • 12

1 Answers1

0

OK, so this isn't the greatest email match engine, but after getting a downvote I realized I hadn't been googling the right information and found a way to count regex matches, so my apologies if I gummed up the system:

^to:(\w+@(\w+\.\w+)[;,]?\s*){2,}$

iopener
  • 187
  • 12