3 ms·
Been there, done that. There's only one way to check email addresses: /.+@.+/ Anything else is going to give you a false negative sooner or later. Yeah, you ca
by captaincrowbar 10y ago
Been there, done that. There's only one way to check email addresses: /.+@.+/
Anything else is going to give you a false negative sooner or later. Yeah, you can spend hours framing a complicated expression that carefully tests for exactly what the current bucket of RFCs specify, but you're guaranteed to run into an MTA somewhere that disagrees with you, and you can argue until the cows come home that you're right and they're wrong, but it's still you that's going to have to change to accommodate them in the end.
- aroch 10y agoI would think you'd use: /.+@.+\..+/
- pmlnr 10y agonope. root@localhost is a valid mail address.
- aroch 10y agoHow often are you validating email addresses for localhost!? Those are pretty much never a valid email for >>>99% of applications
- mason55 10y agoRight, so if you're not going to accept the full RFC then where do you draw the line? Your arbitrary line will assuredly be different from someone else's.
- nothrabannosir 10y agoThat's the whole point of the original post: don't bother thinking about it, let the mta do that for you. The "@" is a courtesy to make sure people didn't mistakenly put their name in. Don't validate, just do a sanity check.
- strictnein 10y agoAnd people are just as likely to type an valid but incorrect email address as a invalid email address.
- nkrisc 10y agoThat's why you also implement an email verification method if you actually care that it's a correct email as well as valid.
- deleted 10y ago[deleted]
- NelsonMinar 10y agoHistorically there have been many valid RFC 822 addresses without an @ in them. I don't know how many can still be delivered to though.