内容简介:x.mail.Session并进行身份验证,现在我得到了它,但只是在深入研究代码之后.在这段时间里,我看到了有史以来最糟糕的代码:javax.mail.Service #connect(String,String,String,String)Version 1.4.1密码何时分配?为什么两次检查null? – 然后意识到其他不属于if if. (这是原始的缩进).回到主题.
x.mail.Session并进行身份验证,现在我得到了它,但只是在深入研究代码之后.
在这段时间里,我看到了有史以来最糟糕的代码:javax.mail.Service #connect(String,String,String,String)Version 1.4.1
if (user == null) {
user = url.getUsername();
if (password == null) // get password too if we need it
password = url.getPassword();
} else {
if (password == null && user.equals(url.getUsername()))
// only get the password if it matches the username
password = url.getPassword();
}
密码何时分配?为什么两次检查null? – 然后意识到其他不属于if if. (这是原始的缩进).回到主题.
至少我发现正确的资源定义是:
<Resource name="email/session"
type="javax.mail.Session"
auth="Container"
password="secret"
mail.debug="false"
mail.transport.protocol="smtp"
mail.smtp.auth="true"
mail.smtp.user="testi"
mail.smtp.host="smtp.xxx.org"
mail.smtp.from="test@example.com"
/>
请注意它是“password”和“mail.smtp.user”或“mail.user”而不是“mail.smtp.password”或“user”.
至少魔术是在Tomcats org.apache.naming.factory.MailSessionFactory中完成的.如果属性密码和属性mail.smtp.user或mail.user退出,则此工厂将javax.mail.Authenticator添加到邮件会话.
现在我的问题是所有这些东西的文档在哪里.特别是关于用户名和密码的配置?
顺便说一句:我解释得更详细一些,以帮助其他人如何解决同样的问题.
以上所述就是小编给大家介绍的《Tomcat中JNDI的Java Mail API配置文档》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- [ Laravel 5.7 文档 ] 快速入门 —— 安装配置
- Spring Cloud 参考文档(外部配置:Archaius)
- 前后端分离ssm配置swagger接口文档
- Open-Falcon安装部署配置说明文档
- avue 1.4.3 更新,新增大量配置化属性,完善使用文档
- avue 1.4.3 更新,新增大量配置化属性,完善使用文档
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Introduction to Computation and Programming Using Python
John V. Guttag / The MIT Press / 2013-7 / USD 25.00
This book introduces students with little or no prior programming experience to the art of computational problem solving using Python and various Python libraries, including PyLab. It provides student......一起来看看 《Introduction to Computation and Programming Using Python》 这本书的介绍吧!