diff --git a/.gitignore b/.gitignore index 01245e03e7631dd34213058ebb7f3418abe6ad08..7ed0d6b679399a08baa8c4e3d4ee2f95d898f0e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -READ.md target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/**/target/ diff --git a/READ.md b/READ.md new file mode 100644 index 0000000000000000000000000000000000000000..83ac6dd8f5557e8ef004186e788f8959ea0b3f5a --- /dev/null +++ b/READ.md @@ -0,0 +1,43 @@ +## 一.说明 + +主要是SpringBoot学习 + +### 二.主要集成 + +- redis + +- mybatis-plus + +- swagger2 + +- logback + +- druid + +- @Aspect切面日志 + +- devtools热部署 + +- mapstruct dto-vo转换 + +- test测试模块 + +- mysql + +- web模块 + +- 发邮件 + + +## 三.链接 + +### 1.访问链接 + +http://localhost:8761/user/all + +### 2.swagger + +http://localhost:8761/swagger-ui.html + + + diff --git a/src/test/java/com/kwan/springbootkwan/UserServiceImplTest.java b/src/test/java/com/kwan/springbootkwan/UserServiceImplTest.java index 0508fc6b4e61e4455f7def4458887c533d4a1d8e..fc07814460dcd34a2c060a9cfed3cad11baa72b7 100644 --- a/src/test/java/com/kwan/springbootkwan/UserServiceImplTest.java +++ b/src/test/java/com/kwan/springbootkwan/UserServiceImplTest.java @@ -8,6 +8,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + @SpringBootTest public class UserServiceImplTest { @@ -15,7 +19,7 @@ public class UserServiceImplTest { @Autowired private UserMapper userService; @Autowired - private ISendMsgHandle isSendMsgHandle; + private ISendMsgHandle emailSendMsgHandle; @Test public void queryAll() { @@ -32,6 +36,69 @@ public class UserServiceImplTest { mailInfo.setReceiver(new String[]{"qinyingjie@deepexi.com"}); mailInfo.setSubject("测试主题"); mailInfo.setContent("邮件内容"); - isSendMsgHandle.sendSimpleTextEmail(mailInfo); + emailSendMsgHandle.sendSimpleTextEmail(mailInfo); + } + + + /** + * 带html + */ + @Test + public void sendHTMLMail() { + MailInfo mailBean = new MailInfo(); + //接收人 + mailBean.setReceiver(new String[]{"qinyingjie@deepexi.com"}); + mailBean.setSubject("SpringBootMailHTML之这是一封HTML格式的邮件"); + //抄送给谁 + mailBean.setCc(new String[]{"786775527@qq.com", "286968900@qq.com"}); + StringBuilder sb = new StringBuilder(); + sb.append("
这是一封HTML邮件...
") + .append("时间为:" + new Date() + "
"); + mailBean.setContent(sb.toString()); + //true、false控制以普通文本发送还是以html格式发送 + emailSendMsgHandle.sendHtmlEmail(mailBean, true); + } + + @Test + void sendEmail() { + MailInfo mailBean = new MailInfo(); + mailBean.setReceiver(new String[]{"qinyingjie@deepexi.com"}); + mailBean.setSubject("SpringBootMailHTML之这是一封HTML格式的邮件"); + //抄送给谁 + mailBean.setCc(new String[]{"786775527@qq.com", "286968900@qq.com"}); + StringBuilder sb = new StringBuilder(); + sb.append("这是一封HTML邮件...
") + .append("时间为:" + new Date() + "
"); + mailBean.setContent(sb.toString()); + mailBean.setAttachFileNames(new String[]{"/Users/Downloads/密码管理.xlsx", "/Users/Downloads/1635834323888.jpg"}); + emailSendMsgHandle.sendEnclosureEmail(mailBean); + } + + @Test + void sendEmail2() { + MailInfo mailBean = new MailInfo(); + mailBean.setReceiver(new String[]{"qinyingjie@deepexi.com"}); + mailBean.setSubject("SpringBootMailHTML之这是一封HTML格式的邮件"); + mailBean.setCc(new String[]{"786775527@qq.com", "286968900@qq.com"}); + StringBuilder sb = new StringBuilder(); + sb.append("这是一封HTML邮件...
") + .append("点击进入百度时间为:" + new Date() + "
"); + mailBean.setContent(sb.toString()); + //附件 + mailBean.setAttachFileNames(new String[]{"/Users/Downloads/密码管理.xlsx", "/Users/Downloads/1635834323888.jpg"}); + //内嵌了多少张图片,如果没有,则new一个不带值的Map + Map