smtp.163.com邮箱服务器
1.开启邮箱服务
2.配置邮件服务
在pom.xml中引入spring-boot-starter-mail相关依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
在application.yml中添加如下配置
mail:
host: smtp.163.com #SMTP服务器地址
username: #登录账号
password: #登录密码或授权码
properties:
from: #邮箱发件人
mail:
smtp:
ssl:
enable: true #开启SSL服务,由于使用的是服务器SSL协议端口号465,所以要开启SSL
auth: true
starttls:
enable: true
required: true
default-encoding: utf-8
port: 465 #SSL协议端口号
参考: