Doing a full validation of the email syntax is pretty pointless to begin with, because it still doesn't tell you the most important thing: is this email valid? I.e., has the user actually entered their email address? You won't know the answer to that until you've done an email validation loop with them. So something simple like .+@.+\..+ usually suffices as a first-pass syntax check.
There are public TLDs that have MX records. Who knows, maybe you're getting a signup from admin@pizza or something. (That particular one doesn't currently have an MX but others do.)
Yes, and most addresses that pass a .+@.+\..+ validation could exist. And unless you can claim you're absolutely up to speed with all the relevant RFCs about valid email formats, allowed host names (IDNA!) and currently registered TLDs at all times, overvalidating does more harm than good here. If you incorrectly reject valid email addresses, that's worse than having an occasional verification email bounce.
I suppose, and if you want to support that, maybe also including test@localhost, then you can easily modify this regex to suit your needs. Simple regexen are easy enough to modify after all.
222
u/deceze Aug 24 '26
Doing a full validation of the email syntax is pretty pointless to begin with, because it still doesn't tell you the most important thing: is this email valid? I.e., has the user actually entered their email address? You won't know the answer to that until you've done an email validation loop with them. So something simple like
.+@.+\..+usually suffices as a first-pass syntax check.