maven
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
配置
spring:
mail:
host: smtp.126.com
port: 25
username: yourname
password: yourpwd
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true
发送
@Autowired
private JavaMailSender mailSender;
@Test
public void sendSimpleMail() throws Exception {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("xxxxxx@126.com");
message.setTo("xxxx@139.com");
message.setSubject("主题:this is subject");
message.setText("this is content");
mailSender.send(message);
}
docs
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。