|
@@ -70,6 +70,9 @@ public class EmailUtil {
|
|
} else if ("BASE64DecoderStream".equals(contentClass)) {
|
|
} else if ("BASE64DecoderStream".equals(contentClass)) {
|
|
if (StrUtil.isNotBlank(part.getFileName())) {
|
|
if (StrUtil.isNotBlank(part.getFileName())) {
|
|
String fileName = MimeUtility.decodeText(part.getFileName());
|
|
String fileName = MimeUtility.decodeText(part.getFileName());
|
|
|
|
+ if (!isSupportedFileType(fileName)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
emailContentInfoDTO.setFileName(fileName);
|
|
emailContentInfoDTO.setFileName(fileName);
|
|
|
|
|
|
String realPath = filePath + emailDate + fileName;
|
|
String realPath = filePath + emailDate + fileName;
|
|
@@ -111,6 +114,13 @@ public class EmailUtil {
|
|
return emailContentInfoDTOList;
|
|
return emailContentInfoDTOList;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static boolean isSupportedFileType(String fileName) {
|
|
|
|
+ if (StrUtil.isBlank(fileName)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return ExcelUtil.isZip(fileName) || ExcelUtil.isExcel(fileName) || ExcelUtil.isPdf(fileName) || ExcelUtil.isHTML(fileName);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据日期过滤邮件
|
|
* 根据日期过滤邮件
|
|
*
|
|
*
|
|
@@ -246,7 +256,8 @@ public class EmailUtil {
|
|
}
|
|
}
|
|
return props;
|
|
return props;
|
|
}
|
|
}
|
|
- public static void senEmail(MailboxInfoDTO mailboxInfoDTO, String emails, File file, JavaMailSender javaMailSender) throws Exception {
|
|
|
|
|
|
+
|
|
|
|
+ public static void senEmail(MailboxInfoDTO mailboxInfoDTO, String emails, File file, JavaMailSender javaMailSender) throws Exception {
|
|
logger.info("send email begin .........");
|
|
logger.info("send email begin .........");
|
|
// 根据Session 构建邮件信息
|
|
// 根据Session 构建邮件信息
|
|
MimeMessage message = javaMailSender.createMimeMessage();
|
|
MimeMessage message = javaMailSender.createMimeMessage();
|
|
@@ -254,8 +265,8 @@ public class EmailUtil {
|
|
Address from = new InternetAddress(mailboxInfoDTO.getAccount());
|
|
Address from = new InternetAddress(mailboxInfoDTO.getAccount());
|
|
String[] emailArr = emails.split(";");
|
|
String[] emailArr = emails.split(";");
|
|
Address[] toArr = new Address[emailArr.length];
|
|
Address[] toArr = new Address[emailArr.length];
|
|
- for(int idx=0;idx<emailArr.length;idx++){
|
|
|
|
- if(StringUtils.isNotEmpty(emailArr[idx])){
|
|
|
|
|
|
+ for (int idx = 0; idx < emailArr.length; idx++) {
|
|
|
|
+ if (StringUtils.isNotEmpty(emailArr[idx])) {
|
|
Address to = new InternetAddress(emailArr[idx]);
|
|
Address to = new InternetAddress(emailArr[idx]);
|
|
toArr[idx] = to;
|
|
toArr[idx] = to;
|
|
}
|
|
}
|
|
@@ -270,10 +281,10 @@ public class EmailUtil {
|
|
BodyPart bodyPart = new MimeBodyPart();
|
|
BodyPart bodyPart = new MimeBodyPart();
|
|
logger.info("组装 htmlText.........");
|
|
logger.info("组装 htmlText.........");
|
|
// 邮件内容
|
|
// 邮件内容
|
|
- String htmlText ="<p>您好,附件为产品的数据未发送到最新,麻烦尽快发送缺失的数据。若是产品清算或者有其他原因不再发送数据,还请将产品的清算日期或者不再发送数据的原因发送给我们,非常感谢~\n</p>";
|
|
|
|
|
|
+ String htmlText = "<p>您好,附件为产品的数据未发送到最新,麻烦尽快发送缺失的数据。若是产品清算或者有其他原因不再发送数据,还请将产品的清算日期或者不再发送数据的原因发送给我们,非常感谢~\n</p>";
|
|
bodyPart.setContent(htmlText, "text/html;charset=utf-8");
|
|
bodyPart.setContent(htmlText, "text/html;charset=utf-8");
|
|
//设置附件
|
|
//设置附件
|
|
- BodyPart filePart=new MimeBodyPart();
|
|
|
|
|
|
+ BodyPart filePart = new MimeBodyPart();
|
|
filePart.setFileName(file.getName());
|
|
filePart.setFileName(file.getName());
|
|
filePart.setDataHandler(
|
|
filePart.setDataHandler(
|
|
new DataHandler(
|
|
new DataHandler(
|