我正在使用gmail smtp主机t通过spring boot和JavaMail Sender发送邮件:
我的邮件属性:
spring.mail.host = smtp.gmail.com spring.mail.username = XXX@gmail.com spring.mail.password = XXX spring.mail.properties.mail.smtp.auth = true spring.mail.properties.mail.smtp.socketFactory.port = 465 spring.mail.properties.mail.smtp.starttls.enable = true spring.mail.properties.mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory spring.mail.properties.mail.smtp.socketFactory.fallback = false
出现错误:
Failed message 1: javax.mail.MessagingException: Could not connect to SMTP host: smtp.9business.fr, port: 25, response: 421] with root cause
即使我正在使用端口465,为什么他仍指向端口25?
实际上,我发现了问题所在,我应该同时使用其中之一是服务器的端口,而另一个则是gmail服务器的端口:
spring.mail.properties.mail.smtp.socketFactory.port = 25 mail.smtp.port= 465