It’s something that’s been bugging me for a long time. All around the web, people are making flawed attempts at validating email addresses, causing a headache for their users, and probably for themselves.
I really started to notice this when I began to use the disposable addresses system that Gmail provides. Any mail sent to <youraddress>+<some_other_string>@gmail.com arrives in the Gmail inbox for <youraddress>@gmail.com. This is quite handy, and I personally use it for automatically tagging email I receive. For instance, for any email related to unicorns, I’d simply enter “<myaddress>+unicorns@gmail.com” on the sign-up form, and my mail filters would automatically tag all mail sent to that address for me (as an aside, these don’t really work as “proper” disposable email addresses as it’s easy to just strip everything after the “+” character in the local part of the address, and get the proper address). Sounds great, right? Well it is, until half of the internet fails at email address validation and rejects it.
The problem is that the email address specification allows for far more than most programmers expect it to. For instance, things like ” ! $ & * – = ^ ` | ~ # % ‘ + / ? _ { } ” are all valid, along with a whole bunch of others (even “@” if you quote or escape it). Some of these are a tad silly. Using another “@” sign by escaping, for instance, is just confusing, and is probably only used by sociopaths. Reject some of those others however, and you’ll start to annoy your users.
I was recently at a talk given by Andrew Godwin at FOSDEM. In that he mentioned a problem Django ran into, where their regular expression used for email validation would hang on long input (scratch that, I think this is the bug he mentioned, that other one is hideously old). After some head scratching, they came up with an improved regular expression, which didn’t have the issue. I’m not sure that either solution actually validates according to the specification though, and if the validation falls on the side of being too strict, it’s probably out there irritating people right now. As a fun aside Perl’s Mail::RFC822::Address module gives you a glimpse at a regular expression that actually follows the specification from RFC822.
Even the best validation is only going to get you a syntactically correct email address, with no guarantee that it actually exists. If you want to know that you’re being given a valid address, send it an email and have the user click a validation link in it, and stop annoying your users!
EDIT: I wrote a little follow up article on some of the points raised by commenters.
Hi,
detecting disposable email addresses is not so easy (except the ones with a + sign) as the number of domains providing such temporary mail services is growing constantly. That’s why I started a new webbased service that anyone can use. It is better than maintaining local blacklists, I guess.
Have a look at http://www.block-disposable-email.com/
Gerold
For what it’s worth, and a little late:
@Captain Irony ( http://blog.sinjakli.co.uk/2011/02/13/email-address-validation-please-stop/#comment-2435 )
“Dots may also be present in the local part, but can not be the first nor last character, nor adjacent to another dot (.) (x2E). – RFC 3696 – 3, RFC 2822 – 3.2.4″
So that address is NOT RFC compliant \o/
Regards
Pleased to be going to your site again, it has been weeks for me personally. Well, this is actually the article that I have been waited for so long. Many thanks,
BookGrill – free ebooks
http://bookgrill.com/?getek.html
Technology books here
Everything is looking great. Thanks for the information!
Thank you for this valuable post. It changed my idea.
Spot on with this write-up, I actually assume this website wants rather more consideration. I’ll most likely be once more to read way more, thanks for that info.
a lieu par Cialis seulement apres une de type 5 PDE5.
Get up to 100000 forum backlinks with our backlinks service & massive targeted traffic Get great web traffic using amazing backlink service today. We are able post your custom message up to 100’000 forums worldwide, get thousands of backlinks and large targeted web traffic in shortest time. Most affordable and most powerful service for web traffic and backlinks in the world!!!! Your post will be published up to 100000 forums worldwide your website or blog will get instant traffic and massive increase in seo rankings just after few days or weeks so your site will get targeted long term traffic from search engines. Order now: backlink service
Dans le cas inverse rester a lecoute des avec une potion magique. http://eurotadalafil.com Manger fumer et boire a repondre a cette derive de lendothelium son la direction dun medecin.