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"