JavaMail specifies a bunch of properties that can be set to configure an SMTP connection. To use STARTTLS it is necessary to set the following property
mail.smtp.starttls.enable=true
Where do I specify the username/password to use the smtp service? Is it enough to specify the:
mail.smtp.user=me
mail.smtp.password=secret
Or do I have to explicitely login using the:
transport.connect(server, userName, password)
Yes, I already tried to do this and it seems that it is necessary to connect using transport.connect(..). But if yes, what are the mail.smtp.user & pass properties for? Are they not enough to use smtp with starttls?
解决方案
Here is my sendEmail method which is using GMail smtp (JavaMail) with STARTTLS
public void sendEmail(String body, String subject, String recipient) throws MessagingException,
最后
以上就是甜美皮带最近收集整理的关于smtp java,JavaMail smtp属性(适用于STARTTLS)的全部内容,更多相关smtp内容请搜索靠谱客的其他文章。
发表评论 取消回复