<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
spring:
mail:
host: smtp.exmail.qq.com
port: 465
username: xxx@xx.com
password: xxxx
protocol: smtp
properties:
mail:
smtp:
auth: true
ssl:
enable: true
socketFactory:
class: com.sun.mail.util.MailSSLSocketFactory
fallback: false
?
@Autowired
JavaMailSender javaMailSender;
public void testSend() {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("XXX@xxx.com"); //发送者邮箱地址 此地址一定要和yml邮箱一致
message.setTo("xxx@xxx.com"); //收件人邮箱地址
message.setSubject("测试主题");
message.setText("测试内容");
jms.send(message);
}
?注意:
如果代码报:501 mail from address must be same as authorization user 错误? ;引起原因是yml中配置的邮箱地址和代码中message.setFrom(xx@xx.com);不一致导致;
?
受全球数据安全政策以及政治因素影响,跨国科技企业涉及大数据处理的业务越来越...
2021年,Linux更加受欢迎了,今天就和大家分享4个可以在Linux上运行的开源服务器...
表单正则验证主要是用来对表单提交信息的过滤,防止sql注入(比如登录界面),上...
js代码 $.ajax({ type : "POST", url : js_path + "/maintainAdd/add", data : J...
highlight: a11y-dark theme: condensed-night-purple 作者Michael Thiessen 译...
作为一名Web开发者而言,如果不借助任何前端框架,从零开始使用HTML和CSS来构建...
本文实例为大家分享了js实现自定义滚动条的具体代码,供大家参考,具体内容如下 ...
usemap是img标签的一个属性,用作指明所使用的图像地图名。 后面的#Map的Map就是...
复制代码 代码如下: html xmlns="" head meta http-equiv="Content-Type" conten...
想了解更多内容,请访问: 51CTO和华为官方战略合作共建的鸿蒙技术社区 https://...