使用163邮箱时,applicationproperties中spring mail 的邮箱参数mailproperties如何设置
时间: 2024-06-09 07:08:34 浏览: 5
如果你使用的是163邮箱,可以在`application.properties`文件中设置以下参数:
```
# 邮箱相关配置
spring.mail.host=smtp.163.com
spring.mail.username=你的163邮箱账号
spring.mail.password=你的163邮箱密码
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.ssl.enable=true
spring.mail.properties.mail.smtp.socketFactory.port=465
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.socketFactory.fallback=false
```
其中`spring.mail.host`表示SMTP服务器的地址,这里是`smtp.163.com`;`spring.mail.username`和`spring.mail.password`表示你的邮箱账号和密码;`spring.mail.properties`表示JavaMail的属性配置,这里设置了SMTP认证、TLS加密和SSL加密等参数。
注意:163邮箱需要使用SSL加密,所以需要设置`spring.mail.properties.mail.smtp.socketFactory.port`和`spring.mail.properties.mail.smtp.socketFactory.class`参数。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)