Skip to content

Commit

Permalink
email
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Jan 23, 2025
1 parent f10491f commit 3ce6840
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/main/java/com/rebuild/core/support/integration/SMSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import java.io.File;
import java.io.IOException;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -194,7 +195,7 @@ public static String sendMail(String to, String subject, String content, File[]
String base64;
try {
byte[] bs = FileUtils.readFileToByteArray(a);
base64 = java.util.Base64.getEncoder().encodeToString(bs);
base64 = Base64.getEncoder().encodeToString(bs);
} catch (IOException ex) {
continue;
}
Expand Down Expand Up @@ -280,10 +281,22 @@ protected static Element getMailTemplate() {
if (Application.devMode()) MT_CACHE = null;
if (MT_CACHE != null) return MT_CACHE.clone();

String content = CommonsUtils.getStringOfRes("i18n/email.zh_CN.html");
Assert.notNull(content, "Cannot load template of email");
Document html = Jsoup.parse(content);
String content = null;
// v3.9.3 从数据目录
File file = RebuildConfiguration.getFileOfData("email.zh_CN.html");
if (file.exists()) {
try {
content = FileUtils.readFileToString(file, AppUtils.UTF8);
} catch (IOException ex) {
log.warn("Cannot read file of email template : {}", file, ex);
}
}
if (content == null) {
content = CommonsUtils.getStringOfRes("i18n/email.zh_CN.html");
}
Assert.notNull(content, "Cannot read email template");

Document html = Jsoup.parse(content);
MT_CACHE = html.body();
return MT_CACHE.clone();
}
Expand Down

0 comments on commit 3ce6840

Please sign in to comment.