使用背景
一般基本配置邮箱,默认使用的端口为25端口,使用这个端口不需要我们去配置ssl或tls协议一般都能成功发送邮件。使用中会有一些服务器屏蔽禁用25端口,如阿里服务器。此时就需要切换端口为465或587端口,并配置ssl协议。
SSL与TLS区别
SSL和TLS 都提供了bai一种加密两台计算机(例如您的计算机和我们的服务器)之间的通信通道的方法。TLS是SSL的后继产品,除非您指的是协议的特定版本,否则SSL和TLS可以互换使用。一般情况下使用ssl配置就可以了。
使用记录
引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
配置properties
下面展示一些 内联代码片
。
spring.mail.default-encoding=UTF-8
spring.mail.host=mail.money.com
spring.mail.password=2020lonely
spring.mail.port=587
spring.mail.username=cheny@slef.com
spring.mail.test-connection=false
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties