修改邮件发送

pull/22/head
rays 2021-08-05 09:32:03 +08:00
parent 42876b9cd1
commit 0f83aded9f
3 changed files with 36 additions and 8 deletions

View File

@ -26,6 +26,11 @@ package cn.stylefeng.roses.kernel.email.api.pojo;
import lombok.Data;
import java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
/**
*
*
@ -36,9 +41,19 @@ import lombok.Data;
public class SendMailParam {
/**
*
*
*/
private String to;
private List<String> tos;
/**
* ,null
*/
private List<String> ccsTos;
/**
* ,null
*/
private List<String> bccsTos;
/**
*
@ -50,4 +65,17 @@ public class SendMailParam {
*/
private String content;
/**
*
*/
private File[] files;
/**
* cid:${cid}
* <p>
* :html
* :1:<img src='cid:image01'>
*/
private Map<String, InputStream> imageMap;
}

View File

@ -58,7 +58,7 @@ public class JavaMailSender implements MailSenderApi {
assertSendMailParams(sendMailParam);
//spring发送邮件
MailUtil.send(mailAccount, CollUtil.newArrayList(sendMailParam.getTo()), sendMailParam.getTitle(), sendMailParam.getContent(), false);
MailUtil.send(mailAccount, sendMailParam.getTos(), sendMailParam.getCcsTos(), sendMailParam.getBccsTos(), sendMailParam.getTitle(), sendMailParam.getContent(), sendMailParam.getImageMap(), false, sendMailParam.getFiles());
}
@Override
@ -68,7 +68,7 @@ public class JavaMailSender implements MailSenderApi {
assertSendMailParams(sendMailParam);
//spring发送邮件
MailUtil.send(mailAccount, CollUtil.newArrayList(sendMailParam.getTo()), sendMailParam.getTitle(), sendMailParam.getContent(), true);
MailUtil.send(mailAccount, sendMailParam.getTos(), sendMailParam.getCcsTos(), sendMailParam.getBccsTos(), sendMailParam.getTitle(), sendMailParam.getContent(), sendMailParam.getImageMap(), true, sendMailParam.getFiles());
}
/**
@ -83,7 +83,7 @@ public class JavaMailSender implements MailSenderApi {
throw new MailException(EmailExceptionEnum.EMAIL_PARAM_EMPTY_ERROR.getErrorCode(), format);
}
if (ObjectUtil.isEmpty(sendMailParam.getTo())) {
if (ObjectUtil.isEmpty(sendMailParam.getTos())) {
String format = StrUtil.format(EmailExceptionEnum.EMAIL_PARAM_EMPTY_ERROR.getUserTip(), "收件人邮箱");
throw new MailException(EmailExceptionEnum.EMAIL_PARAM_EMPTY_ERROR.getErrorCode(), format);
}
@ -98,5 +98,4 @@ public class JavaMailSender implements MailSenderApi {
throw new MailException(EmailExceptionEnum.EMAIL_PARAM_EMPTY_ERROR.getErrorCode(), format);
}
}
}

View File

@ -15,6 +15,7 @@ import cn.stylefeng.roses.kernel.file.api.constants.FileConstants;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import java.util.Collections;
import java.util.Date;
/**
@ -78,7 +79,7 @@ public class CustomerFactory {
String template = CustomerConfigExpander.getRegMailContent();
SendMailParam sendMailParam = new SendMailParam();
sendMailParam.setTo(mail);
sendMailParam.setTos(Collections.singletonList(mail));
sendMailParam.setTitle(title);
sendMailParam.setContent(StrUtil.format(template, verifyCode, verifyCode));
return sendMailParam;
@ -121,7 +122,7 @@ public class CustomerFactory {
String template = CustomerConfigExpander.getResetPwdMailContent();
SendMailParam sendMailParam = new SendMailParam();
sendMailParam.setTo(mail);
sendMailParam.setTos(Collections.singletonList(mail));
sendMailParam.setTitle(title);
sendMailParam.setContent(StrUtil.format(template, randomCode));
return sendMailParam;