Validating an email
This is to verify that I actually own that email address before my account is activated.At this point, why keep parsing email addresses for their format?But what if I told you there were a way to determine whether or not an email is valid without resorting to regular expressions at all? The activation email is a practice that’s been in use for years, but it’s often paired with complex validations that the email is formatted correctly.It’s surprisingly easy, and you’re probably already doing it anyway. If you’re going to send an activation email to users, why bother using a gigantic regular expression?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.But if your address works then why does it matter if it's invalid?
Consequently, the people who make email software have often ignored the RFCs and done their own thing.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.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.
Search for validating an email:
Think about it this way: I register for your website under the email address . That’s probably going to bounce off of the illustrious mail daemon, but the formatting is fine; it’s a valid email address.