Email address validation of Top Level Domain
Asked Answered
C

3

9

Our QA has filed a bug that says top level domain of the email address cannot be of one character.

[email protected]

I am having a hard time looking into standards. Can somebody confirm if setting top level domain minimum length is a right thing to do?

Changeless answered 21/3, 2013 at 0:32 Comment(4)
email validation is hard! z and other stuff is valid.Ladybird
The best way to validate an email address is by sending a verification email. Any other method does not guarantee that the address is valid, merely that it could be valid, and even that is subjective.Jailer
What does the standard say? Does it say that TLD with one character is valid?Changeless
@powtac, although I do agree that for an email .z is valid, for a public email it is not. Actually the email address "foo" is valid too as the default domain is localhost so it is equivalent to "foo@localhost". However, 99.999% of the time, someone who thinks "is this email valid?" does discard all local or intranet email addresses because those are well taken care of without special code.Visceral
R
5

The rules for validating email addresses are as complicated as they are likely to be buggy in their implementation.

Rather than validating an email address, consider verifying it directly instead: http://davidcel.is/blog/2012/09/06/stop-validating-email-addresses-with-regex/

The problem with your case, is that there is a very real possibility that ICANN might introduce single-letter top-level domain names, and individual DNS labels can be of length 1, in fact "bar.z" is a valid email address domain name if sent from within a DNS tree/organization where that exists as a sub-domain (i.e. if the mailserver is smtp.mycompany.org and I've also defined an MX server for bar.z.mycompany.org).

Robinson answered 21/3, 2013 at 0:37 Comment(1)
first check for stupid errors, then send validation email. we need to be kinder to users and help them, not leave them alone in indefinite validation email waiting.Epicalyx
V
1

Note that I wrote a small C library call libtld for that purpose. It may be useful to you. Note that the amount of data required to support all TLDs, world wide, is quite staggering so I would not implement such in Javascript. That being said, maybe if you can compress the data more... The library also includes a PHP extension so you can use the functions and results directly from PHP.

Visceral answered 25/5, 2013 at 10:2 Comment(0)
H
1

Up to now, email top level domain's length should locate in [2,6],but it's not a constant stanard because everything is changing. Validate email is very hard, you can't know whether an email address can actually receive email until you try to send email to it, though it fit email formal standard.

Hedwighedwiga answered 13/12, 2016 at 2:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.