简体   繁体   English

顶级域名的电子邮件地址验证

[英]Email address validation of Top Level Domain

Our QA has filed a bug that says top level domain of the email address cannot be of one character. 我们的QA提交了一个错误,指出电子邮件地址的顶级域名不能是一个字符。

foo@bar.z

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? 有人可以确认设置顶级域最小长度是否正确?

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/ 而不是验证电子邮件地址,请考虑直接验证它: 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 (ie if the mailserver is smtp.mycompany.org and I've also defined an MX server for bar.z.mycompany.org ). 与你的情况的问题,是有一个非常现实的可能性,ICANN可能会推出单字母顶级域名,而个人DNS标签可以是长度为1的,实际上是“bar.z”是一个有效的电子邮件地址域名称,如果从作为子域存在的DNS树/组织内发送(即,如果邮件服务器是smtp.mycompany.org ,我还为bar.z.mycompany.org定义了MX服务器)。

Note that I wrote a small C library call libtld for that purpose. 请注意,我为此目的编写了一个小型C库调用libtld 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. 请注意,在全球范围内支持所有TLD所需的数据量非常惊人,因此我不会在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. 话虽这么说,也许你可以更多地压缩数据......这个库还包括一个PHP扩展,所以你可以直接从PHP使用这些函数和结果。

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. 到目前为止,电子邮件顶级域名的长度应该位于[2,6]中,但它不是一个恒定的标准,因为一切都在变化。 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. 验证电子邮件非常困难,您无法知道电子邮件地址是否可以实际接收电子邮件,直到您尝试向其发送电子邮件,尽管它符合电子邮件正式标准。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM