mirror of https://gitee.com/stylefeng/roses
修改邮件发送
parent
42876b9cd1
commit
0f83aded9f
|
@ -26,6 +26,11 @@ package cn.stylefeng.roses.kernel.email.api.pojo;
|
||||||
|
|
||||||
import lombok.Data;
|
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 {
|
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 String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附件列表
|
||||||
|
*/
|
||||||
|
private File[] files;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片与占位符,占位符格式为cid:${cid}
|
||||||
|
* <p>
|
||||||
|
* 注意:只有发送html邮件,图片才可正常显示
|
||||||
|
* 如:测试图片1:<img src='cid:image01'>
|
||||||
|
*/
|
||||||
|
private Map<String, InputStream> imageMap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class JavaMailSender implements MailSenderApi {
|
||||||
assertSendMailParams(sendMailParam);
|
assertSendMailParams(sendMailParam);
|
||||||
|
|
||||||
//spring发送邮件
|
//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
|
@Override
|
||||||
|
@ -68,7 +68,7 @@ public class JavaMailSender implements MailSenderApi {
|
||||||
assertSendMailParams(sendMailParam);
|
assertSendMailParams(sendMailParam);
|
||||||
|
|
||||||
//spring发送邮件
|
//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);
|
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(), "收件人邮箱");
|
String format = StrUtil.format(EmailExceptionEnum.EMAIL_PARAM_EMPTY_ERROR.getUserTip(), "收件人邮箱");
|
||||||
throw new MailException(EmailExceptionEnum.EMAIL_PARAM_EMPTY_ERROR.getErrorCode(), format);
|
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);
|
throw new MailException(EmailExceptionEnum.EMAIL_PARAM_EMPTY_ERROR.getErrorCode(), format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.StatusEnum;
|
||||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +79,7 @@ public class CustomerFactory {
|
||||||
String template = CustomerConfigExpander.getRegMailContent();
|
String template = CustomerConfigExpander.getRegMailContent();
|
||||||
|
|
||||||
SendMailParam sendMailParam = new SendMailParam();
|
SendMailParam sendMailParam = new SendMailParam();
|
||||||
sendMailParam.setTo(mail);
|
sendMailParam.setTos(Collections.singletonList(mail));
|
||||||
sendMailParam.setTitle(title);
|
sendMailParam.setTitle(title);
|
||||||
sendMailParam.setContent(StrUtil.format(template, verifyCode, verifyCode));
|
sendMailParam.setContent(StrUtil.format(template, verifyCode, verifyCode));
|
||||||
return sendMailParam;
|
return sendMailParam;
|
||||||
|
@ -121,7 +122,7 @@ public class CustomerFactory {
|
||||||
String template = CustomerConfigExpander.getResetPwdMailContent();
|
String template = CustomerConfigExpander.getResetPwdMailContent();
|
||||||
|
|
||||||
SendMailParam sendMailParam = new SendMailParam();
|
SendMailParam sendMailParam = new SendMailParam();
|
||||||
sendMailParam.setTo(mail);
|
sendMailParam.setTos(Collections.singletonList(mail));
|
||||||
sendMailParam.setTitle(title);
|
sendMailParam.setTitle(title);
|
||||||
sendMailParam.setContent(StrUtil.format(template, randomCode));
|
sendMailParam.setContent(StrUtil.format(template, randomCode));
|
||||||
return sendMailParam;
|
return sendMailParam;
|
||||||
|
|
Loading…
Reference in New Issue