7

我们的 QA 提交了一个错误,指出电子邮件地址的顶级域不能是一个字符。

foo@bar.z

我很难研究标准。有人可以确认设置顶级域最小长度是否正确吗?

4

3 回答 3

3

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).

于 2013-03-21T00:37:52.200 回答
1

请注意,我为此编写了一个名为libtld的小型 C 库。它可能对你有用。请注意,支持全球所有 TLD 所需的数据量非常惊人,因此我不会在 Javascript 中实现此类。话虽如此,也许如果您可以更多地压缩数据...该库还包括一个 PHP 扩展,因此您可以直接使用 PHP 的函数和结果。

于 2013-05-25T10:02:51.410 回答
1

到目前为止,电子邮件顶级域的长度应该在[2,6],但它不是一个恒定的标准,因为一切都在变化。验证电子邮件非常困难,在您尝试向其发送电子邮件之前,您无法知道一个电子邮件地址是否真的可以接收电子邮件,尽管它符合电子邮件的正式标准。

于 2016-12-13T02:45:48.277 回答