Validating an email
Most likely she'll say “Oh yes, silly me” and correct it. Sadly, many websites won't let you register an address with a plus sign in it. Occasionally a user might say “Damn right that's my email address. Better register the account before you lose a customer, even if it's not a . This is great for registering with websites because you can see if they've passed your address on to somebody else when email starts arriving addressed to the unique address you gave to the website (e.g. Not because they are trying to defeat your tracking strategy but just because they are crap. Here’s a fairly common code sample from Rails Applications with some sort of authentication system: If you’re experienced at Regex, this seems simple. Sections 3.2.4 and 3.4.1 of the RFC go into the requirements on how an email address needs to be formatted and, well, there’s not much you can’t do in your email address when quotes or backslashes are involved.If (like me when I first saw this) you AREN’T experienced at Regex, it takes a while to parse. The local string (the part of the email address that comes before the @) can contain any of these characters: is a valid email address. For this reason, for a time I began running any email address against the following regular expression instead: Simple, right? This is often the most I do and, when paired with a confirmation field for the email address on your registration form, can alleviate most problems with user error.Messages you receive should be interpreted as the sender intended so long as the meaning is clear. Getting it right is hard because the RFCs that define the conventions are trying to serve many masters and they document conventions that grew up in the early wild west days of email. There's free code out there in many languages that will do this better than anybody's first attempt. If you do try to write validation code yourself then you should at least test it.This is a very valuable principle that allows networked software written by different people at different times to work together. Even if you're adopting somebody else's validator you should test it.Thus it is perfectly possible for you to have been issued an email address by your internet service provider (ISP) that flouts the RFC conventions and is in that sense invalid.
When we have a suggestion for a common typos, we’ll return it along with invalid status, so you can offer the suggestion to your user.
However, in the real world ESPs accept addresses that are not RFC-valid, and reject addresses that are.
When we built our validator, we did so based on real-world data RFC spec to ensure more accurate validation.
There are acknowledged standards for what constitutes a valid email address.
These are defined in the Request For Comments documents (RFCs) written by the lords of the internet.