Hi,

You might want to checkout the perl module Regex::Common::Email::Address

Best Regards

Martin

On 2017-01-06 13:16, Petr Hanousek wrote:
Hello Jeffrey,
thank you, I'll try to implement it here. Wonder if someone has done it
before or if there is any plugin for this? Or (the best way) if some
developer encodes it to some future release of RT? :)
Petr

On 5.1.2017 21:51, Jeffrey Pilant wrote:
Check out
        http://www.regular-expressions.info/email.html
It indicates the 'most' official regex is:
\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*
 |  "(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]
      |  \\[\x01-\x09\x0b\x0c\x0e-\x7f])*")
@ (?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
  |  \[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}
       (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:
          (?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]
          |  \\[\x01-\x09\x0b\x0c\x0e-\x7f])+)
     \])\z

Yeah. Quite a mouthful. This is because there are quite a few ways to express email addresses. And even this is not foolproof.

The same page also has other simpler regex expressions that work a fair amount of the time, but are less complicated, like:
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b

The page claims it is 99% effective.

That, however, does not solve your problem. Just because it is formulated correctly does not mean it is a valid address.

The usual solution is to whitelist the addresses and do a lookup. Any address not found gets added tentatively, but flagged for testing. You can also at this time prompt for acceptance vs. going back to an edit screen. This does require you maintain a list of valid email addresses somewhere. The user list is a likely place, but if you are sending emails to people who are not users, then that fails.

/jeff
________________________________________________________________________
The information contained in this e-mail is for the exclusive use of the
intended recipient(s) and may be confidential, proprietary, and/or
legally privileged.  Inadvertent disclosure of this message does not
constitute a waiver of any privilege.  If you receive this message in
error, please do not directly or indirectly use, print, copy, forward,
or disclose any part of this message.  Please also delete this e-mail
and all copies and notify the sender.  Thank you.
________________________________________________________________________

Reply via email to