|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.java3y.austin.handler.handler.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.extra.mail.MailAccount;
|
|
|
|
|
import cn.hutool.extra.mail.MailUtil;
|
|
|
|
@ -23,7 +24,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 邮件发送处理
|
|
|
|
@ -56,9 +57,9 @@ public class EmailHandler extends BaseHandler implements Handler {
|
|
|
|
|
EmailContentModel emailContentModel = (EmailContentModel) taskInfo.getContentModel();
|
|
|
|
|
MailAccount account = getAccountConfig(taskInfo.getSendAccount());
|
|
|
|
|
try {
|
|
|
|
|
File file = StrUtil.isNotBlank(emailContentModel.getUrl()) ? AustinFileUtils.getRemoteUrl2File(dataPath, emailContentModel.getUrl()) : null;
|
|
|
|
|
String result = Objects.isNull(file) ? MailUtil.send(account, taskInfo.getReceiver(), emailContentModel.getTitle(), emailContentModel.getContent(), true) :
|
|
|
|
|
MailUtil.send(account, taskInfo.getReceiver(), emailContentModel.getTitle(), emailContentModel.getContent(), true, file);
|
|
|
|
|
List<File> files = StrUtil.isNotBlank(emailContentModel.getUrl()) ? AustinFileUtils.getRemoteUrl2File(dataPath, StrUtil.split(emailContentModel.getUrl(), StrUtil.COMMA)) : null;
|
|
|
|
|
String result = CollUtil.isEmpty(files) ? MailUtil.send(account, taskInfo.getReceiver(), emailContentModel.getTitle(), emailContentModel.getContent(), true) :
|
|
|
|
|
MailUtil.send(account, taskInfo.getReceiver(), emailContentModel.getTitle(), emailContentModel.getContent(), true, files.toArray(new File[files.size()]));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("EmailHandler#handler fail!{},params:{}", Throwables.getStackTraceAsString(e), taskInfo);
|
|
|
|
|
return false;
|
|
|
|
|