diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js
index 7459e4bc..03dbdf4c 100644
--- a/frontend/src/store/index.js
+++ b/frontend/src/store/index.js
@@ -34,6 +34,7 @@ export const useGlobalState = createGlobalState(
cfTurnstileSiteKey: '',
enableWebhook: false,
isS3Enabled: false,
+ enableSendMail: false,
showGithub: true,
disableAdminPasswordCheck: false,
enableAddressPassword: false,
diff --git a/frontend/src/views/Index.vue b/frontend/src/views/Index.vue
index f0efcd3e..a6161ba9 100644
--- a/frontend/src/views/Index.vue
+++ b/frontend/src/views/Index.vue
@@ -156,15 +156,15 @@ onMounted(() => {
-
-
+
-
+
diff --git a/worker/src/commom_api.ts b/worker/src/commom_api.ts
index e3856bc8..52b7340a 100644
--- a/worker/src/commom_api.ts
+++ b/worker/src/commom_api.ts
@@ -3,6 +3,7 @@ import { Hono } from 'hono'
import utils from './utils';
import { CONSTANTS } from './constants';
import { isS3Enabled } from './mails_api/s3_attachment';
+import { isAnySendMailEnabled } from './common';
const api = new Hono
@@ -38,6 +39,7 @@ api.get('/open_api/settings', async (c) => {
"cfTurnstileSiteKey": c.env.CF_TURNSTILE_SITE_KEY,
"enableWebhook": utils.getBooleanValue(c.env.ENABLE_WEBHOOK),
"isS3Enabled": isS3Enabled(c),
+ "enableSendMail": isAnySendMailEnabled(c),
"version": CONSTANTS.VERSION,
"showGithub": !utils.getBooleanValue(c.env.DISABLE_SHOW_GITHUB),
"disableAdminPasswordCheck": utils.getBooleanValue(c.env.DISABLE_ADMIN_PASSWORD_CHECK),
diff --git a/worker/src/common.ts b/worker/src/common.ts
index 708b0d1e..9f2d2d35 100644
--- a/worker/src/common.ts
+++ b/worker/src/common.ts
@@ -1,7 +1,8 @@
import { Context } from 'hono';
import { Jwt } from 'hono/utils/jwt'
+import { WorkerMailerOptions } from 'worker-mailer';
-import { getBooleanValue, getDomains, getStringValue, getIntValue, getUserRoles, getDefaultDomains, getJsonSetting, getAnotherWorkerList, hashPassword } from './utils';
+import { getBooleanValue, getDomains, getStringValue, getIntValue, getUserRoles, getDefaultDomains, getJsonSetting, getAnotherWorkerList, hashPassword, getJsonObjectValue } from './utils';
import { unbindTelegramByAddress } from './telegram_api/common';
import { CONSTANTS } from './constants';
import { AdminWebhookSettings, WebhookMail, WebhookSettings } from './models';
@@ -9,6 +10,37 @@ import i18n from './i18n';
const DEFAULT_NAME_REGEX = /[^a-z0-9]/g;
+/**
+ * Check if send mail is enabled for a specific domain
+ */
+export const isSendMailEnabled = (
+ c: Context,
+ mailDomain: string
+): boolean => {
+ // Check resend token for domain or global
+ const resendEnabled = c.env.RESEND_TOKEN || c.env[
+ `RESEND_TOKEN_${mailDomain.replace(/\./g, "_").toUpperCase()}`
+ ];
+ if (resendEnabled) return true;
+
+ // Check SMTP config for domain
+ const smtpConfigMap = getJsonObjectValue>(c.env.SMTP_CONFIG);
+ if (smtpConfigMap && smtpConfigMap[mailDomain]) return true;
+
+ // Check SEND_MAIL binding
+ if (c.env.SEND_MAIL) return true;
+
+ return false;
+}
+
+/**
+ * Check if send mail is enabled for any configured domain
+ */
+export const isAnySendMailEnabled = (c: Context): boolean => {
+ const domains = getDomains(c);
+ return domains.some(domain => isSendMailEnabled(c, domain));
+}
+
export const generateRandomName = (c: Context): string => {
// name min length min 1
const minLength = Math.max(