最近把算打注册邮箱验证弄一下
首先我们要在SpringBoot里配置pom.xml文件
1
2
3
4
|
<dependency>
<groupId>org.springframework.boot
</groupId>
<artifactId>spring-boot-starter-mail
</artifactId>
</dependency>
|
这个就是spring推出的JavaMailSender
比起之前的JavaMail 更加简化了邮件发送的过程
在application.properties中添加邮箱配置
1
2
3
4
5
6
|
spring.mail.host=smtp.mxhichina.com
spring.mail.username=邮箱账号
spring.mail.password=密码
spring.mail.default-encoding=UTF-8
mail.fromMail.addr=你想要用来发送的邮箱
|
第一个是smtp服务(详细Google下,确保你的邮箱开启了smtp)
编写一个简单的类来测试
为了防止初学者导错包,我把import也写进来
1
2
3
4
5
6
7
8
9
10
11
12
|