Others_2_Mail

hayeka發表於2020-03-08
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
spring:
  mail:
    username: 1332726782@qq.com
    password: ************
    host: smtp.qq.com
  properties:
    mail:
      smtp:
        ssl:
          enable: true
package cn.boxku;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;

@SpringBootTest
class AsynchronousApplicationTests {


    @Autowired
    JavaMailSenderImpl javaMailSender;

    @Test
    void contextLoads() {
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setSubject("郭張馳你好");
        simpleMailMessage.setText("謝謝你抽時間來學習");
        simpleMailMessage.setTo("690690661@qq.com");
        simpleMailMessage.setFrom("1332726782@qq.com");
        javaMailSender.send(simpleMailMessage);
    }

}
本作品採用《CC 協議》,轉載必須註明作者和本文連結

一個從事軟體開發職業的經濟愛好者