提交 f2a56f4c 编写于 作者: Q qinyingjie

fix:概要

上级 74a5a03a
READ.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
......
## 一.说明
主要是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
......@@ -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("<h2>SpringBoot测试邮件HTML</h2>")
.append("<p style='text-align:left'>这是一封HTML邮件...</p>")
.append("<p> 时间为:" + new Date() + "</p>");
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("<h2>SpringBoot测试邮件HTML</h2>")
.append("<p style='text-align:left'>这是一封HTML邮件...</p>")
.append("<p> 时间为:" + new Date() + "</p>");
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("<h2>SpringBoot测试邮件HTML</h2>")
.append("<p style='text-align:left'>这是一封HTML邮件...</p>")
.append("<a href=http://www.baidu.com>点击进入百度</a><br/>")
//内嵌图片
.append("<img src=\"cid:a00000001\"><br/><br/>")
.append("<img src=\"cid:a00000002\">")
.append("<p> 时间为:" + new Date() + "</p>");
mailBean.setContent(sb.toString());
//附件
mailBean.setAttachFileNames(new String[]{"/Users/Downloads/密码管理.xlsx", "/Users/Downloads/1635834323888.jpg"});
//内嵌了多少张图片,如果没有,则new一个不带值的Map
Map<String, String> image = new HashMap<>();
image.put("a00000001", "/Users/Downloads/WechatIMG22.jpg");
image.put("a00000002", "/Users/Downloads/face_1631083961355.png");
mailBean.setImageMap(image);
emailSendMsgHandle.sendEnclosureEmail(mailBean);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册