Gmail as JavaMail SMTP server

雨燕双飞 提交于 2019-12-02 10:03:28

The first,

message.setFrom(new InternetAddress(USERNAME));

is using the RFC 5321 - Section 3.3 Mail Transactions MAIL command (which includes FROM). Similarly, the mail.smtp.auth appears to be optional in

props.put("mail.smtp.auth", "true");`

because the library assumes you want to use mail.smtp.auth when you specify a USERNAME and PASSWORD at

Transport.send(message, USERNAME, PASSWORD);

the Transport.send(Message, String, String) Javadoc says (in part)

Use the specified user name and password to authenticate to the mail server.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!