SpringBoot使用QQ郵箱發送郵件25端口被封了怎么辦?
作者:Jack佳
我上面有一篇發送郵箱的總結,總結郵箱的發送使用方法,因為本地測試用的qq郵箱25沒問題,公司的郵箱非25端口使用也沒問題,但是部署到自己的阿里云服務器上的時候一直報錯,認證不通過,后來跟蹤確認是阿里云會封25端口,防止濫用,當然如果去解封25端口的話也可以,本文是介紹不解封25端口怎樣使用qq郵箱發送郵件。
本文轉載自微信公眾號「Java時間屋」,作者Jack佳。轉載本文請聯系Java時間屋公眾號。
- 前言
- 1.SpringBoot發送郵件配置:
- 結尾
前言
我上面有一篇發送郵箱的總結,總結郵箱的發送使用方法,因為本地測試用的qq郵箱25沒問題,公司的郵箱非25端口使用也沒問題,但是部署到自己的阿里云服務器上的時候一直報錯,認證不通過,后來跟蹤確認是阿里云會封25端口,防止濫用,當然如果去解封25端口的話也可以,本文是介紹不解封25端口怎樣使用qq郵箱發送郵件。
1.SpringBoot發送郵件配置:
1.1添加依賴:
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-mail</artifactId>
- </dependency>
1.2賬號配置(不使用25端口改用465端口進行發送);
- spring.mail.protocol=smtp
- ##比較重要的
- spring.mail.port=465
- spring.mail.properties.mail.smtp.auth=true
- spring.mail.properties.mail.transport.protocol=smtp
- spring.mail.properties.mail.smtp.socketFactory.port=465
- spring.mail.properties.mail.smtp.port=465
- spring.mail.properties.mail.smtp.connectiontimeout=15000
- spring.mail.properties.mail.smtp.socketFactory.fallback=false
- spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
- spring.mail.host=smtp.qq.com
- #下面的配置qq是一樣的不區分,但是公司的郵箱賬號大多是是沒后綴的
- spring.mail.username=xxxxx@qq.com
- mail.address=xxxxx@qq.com
- #郵箱的認證密碼。如果是qq和163的話是鑒權碼,公司郵箱的話是密碼
- spring.mail.password=xxxxxxxxxx
- #編碼類型
- spring.mail.default-encoding=UTF-8
結尾
上面就是我實戰的qq郵箱不使用25端口使用465端口的配置實戰,當時在自己的服務器上面搞了很長時間才搞定,也是自己的心得總結,希望能幫助到使用的朋友們
責任編輯:武曉燕
來源:
Java時間屋