From 6f3cdad1e767b55b3e3d1360a0a362f9c59b1d1b Mon Sep 17 00:00:00 2001 From: Deng Junhai Date: Sun, 23 Jun 2024 03:04:52 +0800 Subject: [PATCH] feat: SMTP Compatibility Enhancement and SSL Protocol Support (#174) --- app/src/admin/api/system.ts | 2 ++ app/src/resources/i18n/cn.json | 1 + app/src/resources/i18n/en.json | 1 + app/src/resources/i18n/ja.json | 1 + app/src/resources/i18n/ru.json | 1 + app/src/routes/admin/System.tsx | 39 +++++++++++++++++++++++++++++---- channel/system.go | 5 ++++- utils/smtp.go | 17 ++++++++++---- 8 files changed, 58 insertions(+), 9 deletions(-) diff --git a/app/src/admin/api/system.ts b/app/src/admin/api/system.ts index 39a387fd..89d8f8d3 100644 --- a/app/src/admin/api/system.ts +++ b/app/src/admin/api/system.ts @@ -20,6 +20,7 @@ export type GeneralState = { export type MailState = { host: string; + protocol: boolean; port: number; username: string; password: string; @@ -137,6 +138,7 @@ export const initialSystemState: SystemProps = { auth_footer: false, }, mail: { + protocol: false, host: "", port: 465, username: "", diff --git a/app/src/resources/i18n/cn.json b/app/src/resources/i18n/cn.json index ed015a28..92836ac9 100644 --- a/app/src/resources/i18n/cn.json +++ b/app/src/resources/i18n/cn.json @@ -704,6 +704,7 @@ "debugMode": "调试模式", "debugModeTip": "调试模式,开启后日志将输出详细的请求参数等的日志,用于排查问题", "mailHost": "发件域名", + "mailProtocol": "发件协议", "mailPort": "SMTP 端口", "mailUser": "用户名", "mailPass": "密码", diff --git a/app/src/resources/i18n/en.json b/app/src/resources/i18n/en.json index 5038518b..da70b227 100644 --- a/app/src/resources/i18n/en.json +++ b/app/src/resources/i18n/en.json @@ -513,6 +513,7 @@ "backend": "Backend Domain", "backendTip": "Backend domain name (docker installation default path is/api), used to receive callbacks and storage, etc., default is empty\nExample: {{backend}}", "mailHost": "Mail Host", + "mailProtocol": "Mail Protocol", "mailPort": "SMTP Port", "mailUser": "Username", "mailPass": "Password", diff --git a/app/src/resources/i18n/ja.json b/app/src/resources/i18n/ja.json index 7bd95bf5..f29426b0 100644 --- a/app/src/resources/i18n/ja.json +++ b/app/src/resources/i18n/ja.json @@ -513,6 +513,7 @@ "backend": "バックエンドドメイン", "backendTip": "バックエンドドメイン名( dockerインストールのデフォルトパスは/api )、コールバックやストレージなどを受信するために使用、デフォルトは空です\n例:{{ backend}}", "mailHost": "送信ドメイン名", + "mailProtocol": "送信プロトコル", "mailPort": "SMTPポート", "mailUser": "ユーザー名", "mailPass": "パスワード", diff --git a/app/src/resources/i18n/ru.json b/app/src/resources/i18n/ru.json index f01618df..8b25a2b9 100644 --- a/app/src/resources/i18n/ru.json +++ b/app/src/resources/i18n/ru.json @@ -513,6 +513,7 @@ "backend": "Домен бэкэнда", "backendTip": "Имя домена бэкенда (путь установки докера по умолчанию -/api), используется для получения обратных вызовов и хранения и т. д., значение по умолчанию пусто\nПример: {{backend}}", "mailHost": "Почтовый хост", + "mailProtocol": "Протокол отправки", "mailPort": "Порт SMTP", "mailUser": "Имя пользователя", "mailPass": "Пароль", diff --git a/app/src/routes/admin/System.tsx b/app/src/routes/admin/System.tsx index b71feda6..a71262fb 100644 --- a/app/src/routes/admin/System.tsx +++ b/app/src/routes/admin/System.tsx @@ -12,6 +12,13 @@ import Paragraph, { ParagraphSpace, } from "@/components/Paragraph.tsx"; import { Button } from "@/components/ui/button.tsx"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select.tsx"; import { Label } from "@/components/ui/label.tsx"; import { Input } from "@/components/ui/input.tsx"; import { useMemo, useReducer, useState } from "react"; @@ -283,8 +290,8 @@ function Mail({ data, dispatch, onChange }: CompProps) { data.username.length > 0 && data.password.length > 0 && data.from.length > 0 && - /\w+@\w+\.\w+/.test(data.from) && - !data.username.includes("@") + data.username.includes("@") && + !/\w+@/.test(data.from) ); }, [data]); @@ -332,6 +339,30 @@ function Mail({ data, dispatch, onChange }: CompProps) { placeholder={`smtp.qcloudmail.com`} /> + + + +