关于javamail 使用SSl方式发送邮件的问题。我在官网上面终于找到答案了。
一直连接不上stmp.**.com:465的服务器时因为需要证书,而网上提供的生成证书的一个..java根本就没有用。
最后在官网上面看到了这段话。
In earlier releases it was necessary to explicitly set a socket factory property to enable use of SSL. In almost all cases, this is no longer necessary. SSL support is built in. However, there is one case where a special socket factory may be needed. JavaMail now includes a special SSL socket factory that can simplify dealing with servers with self-signed certificates. While the recommended approach is to include the certificate in your keystore as described above, the following approach may be simpler in some cases. The class com.sun.mail.util.MailSSLSocketFactory can be used as a simple socket factory that allows trusting all hosts or a specific set of hosts. For example: MailSSLSocketFactory sf = new MailSSLSocketFactory(); sf.setTrustAllHosts(true); // or // sf.setTrustedHosts(new String[] { "my-server" }); props.put("mail.smtp.ssl.enable", "true"); // also use following for additional safety //props.put("mail.smtp.ssl.checkserveridentity", "true"); props.put("mail.smtp.ssl.socketFactory", sf); Use of MailSSLSocketFactory avoids the need to add the certificate to your keystore as described above, or configure your own TrustManager as described below.(使用MailSSLSocketFactory避免了需要添加证书,你的密钥库如上所述,或配置自己的TrustManager。如下所述。
实在是高兴啊。使用这个方法后马上使用SSL发送邮件的方式,发送成功了。
官网还提供了一个自己实现的加密管理类,可以使用。在这里我就不贴上来了。直接上官网的地址。
http://www.oracle.com/technetwork/java/javamail145sslnotes-1562622.html
本人英语水凭能力不行,不能翻译。如果英语水平好。翻译出来,绝对是一个很好的资源。
相关推荐
NULL 博文链接:https://fableking.iteye.com/blog/929726
javamail发送、接收邮件详细教程
javamail问题及解决方案源码
javaMail 如果需要ssl加密处理的,建议使用chilkat,如果你是牛人,那你自己实现,其实张孝详老师写过一本关于javamail的书籍,大家可以参考,但是对于邮件加密这块没有做太多说明,java网络编程这本书中,对ssl加密...
javaMail
关于javaMail的资料关于javaMail的资料关于javaMail的资料关于javaMail的资料
NULL 博文链接:https://surpass-li.iteye.com/blog/1100515
JavaMail发送和接受邮件的一个小例子, 含文本,图片, 附件等复杂格式
javaMail javaMail javaMail javaMail javaMail javaMail javaMail
javamail的jar包:javamail-1.6; javamail的jar包:javamail-1.6
JAVAMAIL开发JAVAMAIL开发
javamail开发,带图形界面,邮件的发送,接收,带附件,html,邮件解析
javamail中文API文档 方法解释详细。
javamail.jar,javamail资源包
javaMail示例javaMail示例javaMail示例javaMail示例javaMail示例javaMail示例,我自己做的,保证运行成功,里面jar包都有,只需导入即可,把邮箱设置一下就可以了。
JavaMail JavaMail JavaMail JavaMail JavaMail JavaMail JavaMail
javamail 张孝祥视频讲解源码 有于太大 分三部分长传
javamail发送邮件实例 javamail 发送邮件 文本编辑器 kindeditor
NULL 博文链接:https://gaofeng2001-ren.iteye.com/blog/288956