1. 程式人生 > >springboot 傳送郵件 465埠

springboot 傳送郵件 465埠

springboot預設使用的是25埠.之前寫的程式在本地傳送郵件沒有問題,後來放到伺服器上,傳送失敗.

我們的伺服器使用的是阿里雲,原因就是因為阿里雲伺服器預設是禁止25埠的.所用只能改用  465或者其他埠.

具體配置如下:

#email
spring.mail.host=smtp.qq.com
spring.mail.username=傳送的QQ郵箱
spring.mail.password=如果是qq郵箱,這個地方是授權碼 ,不是密碼
spring.mail.properties.mail.smtp.ssl.trust=smtp.qq.com
#SSL證書Socket工廠
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
#使用SMTPS協議465埠
spring.mail.properties.mail.smtp.socketFactory.port=465
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true