前言
实现登录注册功能的时候,一些软件总是要手机号验证码或者邮件验证码,手机号验证码功能的实现是需要付费使用的,而且也比较容易搭建,例如阿里云的短信验证码服务,有说明文档给我们参考,比较容易实现。
1 邮件发送类依赖导入
springboot集成了邮件发送的类,Thymeleaf是为了邮件发送的HTML模板而导入的,在pom.xml导入如下依赖。
<!--springboot邮件发送-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!--thymeleaf-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2 配置发件邮箱的信息
邮箱以网易邮箱为例,登录之后点击设置,选择POP3/SMTP/IMAP
,将POP3/SMTP服务
开启,然后新增授权码,根据网页提示新增完毕将授权码复制保存起来。根据网易邮箱的提示