From cc749a3dce81d1cc43616b0b69d1dfc61b5c5273 Mon Sep 17 00:00:00 2001 From: smail Date: Sun, 27 Sep 2026 00:01:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=8E=E7=A1=AE=E6=98=BE=E7=A4=BA=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E9=80=9A=E7=9F=A5=E5=9C=B0=E5=9D=80=E5=8F=AA=E5=8F=91?= =?UTF-8?q?=E4=B8=8D=E6=94=B6=E7=9A=84=E6=8A=95=E9=80=92=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/services/logstore/mail.go | 4 ++++ backend/utils/send/send.go | 2 +- backend/utils/validation/notification.go | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/services/logstore/mail.go b/backend/services/logstore/mail.go index b41680b..29654cf 100644 --- a/backend/services/logstore/mail.go +++ b/backend/services/logstore/mail.go @@ -9,6 +9,8 @@ import ( "net/textproto" "strconv" "time" + + "git.pcux.cn/xuans/Smail/utils/validation" ) type MailDetails struct { @@ -25,6 +27,8 @@ func MailFailureReason(err error) string { var protocol *textproto.Error var network net.Error switch { + case errors.Is(err, validation.ErrNotificationRecipient): + return "系统通知地址仅用于发信,不接受收信,请改用普通邮箱地址" case errors.As(err, &certificate): return "对端证书验证失败" case errors.As(err, &dns): diff --git a/backend/utils/send/send.go b/backend/utils/send/send.go index 40de08b..84699bb 100644 --- a/backend/utils/send/send.go +++ b/backend/utils/send/send.go @@ -136,7 +136,7 @@ func parseRecipientAddress(user *parsemail.User) (string, string, error) { } address := strings.TrimSpace(user.EmailAddress) if validation.IsNotificationAddress(address, config.CurrentMailDomains().Accepted) { - return address, "", errors.New("notification address does not accept mail") + return address, "", validation.ErrNotificationRecipient } if address == "" || address != user.EmailAddress { return address, "", errors.New("recipient address is empty or contains surrounding whitespace") diff --git a/backend/utils/validation/notification.go b/backend/utils/validation/notification.go index 16e68b8..34e40a5 100644 --- a/backend/utils/validation/notification.go +++ b/backend/utils/validation/notification.go @@ -1,6 +1,11 @@ package validation -import "strings" +import ( + "errors" + "strings" +) + +var ErrNotificationRecipient = errors.New("notification address does not accept mail") // 加号不属于可注册账号字符,保留地址不会占用普通用户的邮箱。 const NotificationLocalPart = "notification+system"