feat: add global forward address list (#288)

This commit is contained in:
Dream Hunter
2024-05-31 23:21:12 +08:00
committed by GitHub
parent f882e4cf97
commit 7a368d7b23
7 changed files with 36 additions and 0 deletions
+11
View File
@@ -1,5 +1,6 @@
import { Context } from "hono";
import { getEnvStringList } from "../utils";
import { sendMailToTelegram } from "../telegram_api";
import { Bindings, HonoCustomType } from "../types";
import { auto_reply } from "./auto_reply";
@@ -25,6 +26,16 @@ async function email(message: ForwardableEmailMessage, env: Bindings, ctx: Execu
console.log(`Failed save message from ${message.from} to ${message.to}`);
}
// forward email
try {
const forwardAddressList = getEnvStringList(env.FORWARD_ADDRESS_LIST)
for (const forwardAddress of forwardAddressList) {
await message.forward(forwardAddress);
}
} catch (error) {
console.log("forward email error", error);
}
// send email to telegram
try {
await sendMailToTelegram(