spring:
mail:
username: demoniscoding@163.com
host: smtp.163.com
password: 你的密码
properties:
mail:
smtp:
starttls:
enable: false
required: false
port: 25
yml文件配置如上
@Test public void sendSimpleMail() throws Exception { SimpleMailMessage message = new SimpleMailMessage(); message.setFrom("demoniscoding@163.com"); message.setTo("接收邮件的邮箱"); message.setSubject("主题:简单邮件"); message.setText("测试邮件内容"); mailSender.send(message); }