5 ms·
My current policy on validating email addresses is to issue a warning if a given email address fails a check against a standard that covers the vast majority of
by bdfh42 17y ago
My current policy on validating email addresses is to issue a warning if a given email address fails a check against a standard that covers the vast majority of addresses in use. Validating against the whole range of possible address content is near pointless. The warning simply asks the user to check their email in case of errors but allows a page submission following the display of that warning.
- ovi256 17y agoThe problem is that the RFC is amazingly permissive : almost anything goes in email adresses, including whitespace! A RFC-compliant regex is incredibly complex [1]. Furthermore, one would need to read not one, but five RFCs in order to grok everything: http://tools.ietf.org/html/rfc5322 http://tools.ietf.org/html/rfc5322 http://tools.ietf.org/html/rfc3696 http://tools.ietf.org/html/rfc3696 http://tools.ietf.org/html/rfc5321 http://tools.ietf.org/html/rfc5321 http://tools.ietf.org/html/rfc4291#section-2.2 http://tools.ietf.org/html/rfc4291#section-2.2 http://tools.ietf.org/html/rfc1123#section-2.1 http://tools.ietf.org/html/rfc1123#section-2.1 [1] Great overview of the problem, plus a PHP validator. http://www.dominicsayers.com/isemail/ http://www.dominicsayers.com/isemail/
- cperciva 17y agoMy current policy on validating email addresses is to issue a warning if a given email address fails a check against a standard that covers the vast majority of addresses in use. My policy on validating email addresses is "if I send you an email and it arrives, your email address is valid". Why do you need to "validate" an email address? Knowing that an address is syntactically valid doesn't do anything to confirm that it will reach the intended target.
- bdfh42 17y agoYou are correct - but - at your initial point of contact you have (perhaps) a single opportunity to make contact with your prospective customer. You should do all you can (without boring or annoying your prospect) to capture enough accurate information to ensure that the next step succeeds. I agree - long term relationships are built on (in the context of this conversation) an exchange of emails but why blow it at the first hurdle?
- deleted 17y ago[deleted]
- kree10 17y agoAgreed. At [old job] we saw a lot of user-entered e-mail addresses that were "correct" (according to so-called validators) but wrong, like "www.screenname@aol.com" or "example@yahoo".
- Hexstream 17y ago"Knowing that an address is syntactically valid doesn't do anything to confirm that it will reach the intended target." However, knowing that an address is syntactically invalid does confirm that it won't reach the intended target. If you don't mess up the validation. Might be better than having the user wait infinitely for an important transactional email that will never arrive because of a dumb typo.
- nailer 17y agoMine is not to re-write the wheel. Writing a correct email address is indeed non-trivial, but there's at least one well known module written by someone who's actually read the RFCs and won't trash users using plussing and minusing. Use that, don't write your own.
- yhnbgty 17y agoDepends on your customer base. It might be better to reject one show-off who managed to put a backspace in his email in return for helping 1000s of customers who enter www.name@aol.com It's possible to have a 6 character email address, but for most users checking that they have entered more than 6 chars would be good.