This commit is contained in:
parent
317656737a
commit
cc749a3dce
@ -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):
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user