简体   繁体   English

javax.mail.internet.InternetAddress RFC 822验证

[英]javax.mail.internet.InternetAddress RFC 822 validation

I would assume that the following would throw but it doesn't. 我认为以下内容会抛出,但事实并非如此。

new javax.mail.internet.InternetAddress( "a@b......." ).validate

My javax.mail version is 1.4. 我的javax.mail版本是1.4。 (and java version 8 if it matters). (和Java版本8,如果有关系的话)。 Is this a valid email address according to RFC822 which validate() purports to conform to? 这是RFC822声称符合的符合RFC822的有效电子邮件地址吗? http://sphinx.mythic-beasts.com/~pdw/cgi-bin/emailvalidate says that the above is not a valid RFC822 email address. http://sphinx.mythic-beasts.com/~pdw/cgi-bin/emailvalidate表示上述不是有效的RFC822电子邮件地址。

From the documentation : 文档中

The current implementation checks many, but not all, syntax rules. 当前的实现检查许多但不是全部语法规则。

If you can, upgrade your JavaMail version. 如果可以,请升级您的JavaMail版本。

public static void main(String[] args) throws Exception {
    Session.getInstance(new Properties()).setDebug(true);
    new javax.mail.internet.InternetAddress("a@b......." ).validate();
}

Outputs: 输出:

DEBUG: setDebug: JavaMail version 1.5.4
Exception in thread "main" javax.mail.internet.AddressException: Domain contains dot-dot in string ``a@b.......''
     at javax.mail.internet.InternetAddress.checkAddress(InternetAddress.java:1282)
     at javax.mail.internet.InternetAddress.parse(InternetAddress.java:1099)
     at javax.mail.internet.InternetAddress.parse(InternetAddress.java:638)
     at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:111)

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

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