明确显示系统通知地址只发不收的投递失败原因
This commit is contained in:
parent
50244e2c05
commit
d4eff5deb5
@ -9,6 +9,8 @@ import (
|
|||||||
"net/textproto"
|
"net/textproto"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.pcux.cn/xuans/Smail/utils/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MailDetails struct {
|
type MailDetails struct {
|
||||||
@ -25,6 +27,8 @@ func MailFailureReason(err error) string {
|
|||||||
var protocol *textproto.Error
|
var protocol *textproto.Error
|
||||||
var network net.Error
|
var network net.Error
|
||||||
switch {
|
switch {
|
||||||
|
case errors.Is(err, validation.ErrNotificationRecipient):
|
||||||
|
return "系统通知地址仅用于发信,不接受收信,请改用普通邮箱地址"
|
||||||
case errors.As(err, &certificate):
|
case errors.As(err, &certificate):
|
||||||
return "对端证书验证失败"
|
return "对端证书验证失败"
|
||||||
case errors.As(err, &dns):
|
case errors.As(err, &dns):
|
||||||
|
|||||||
@ -136,7 +136,7 @@ func parseRecipientAddress(user *parsemail.User) (string, string, error) {
|
|||||||
}
|
}
|
||||||
address := strings.TrimSpace(user.EmailAddress)
|
address := strings.TrimSpace(user.EmailAddress)
|
||||||
if validation.IsNotificationAddress(address, config.CurrentMailDomains().Accepted) {
|
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 {
|
if address == "" || address != user.EmailAddress {
|
||||||
return address, "", errors.New("recipient address is empty or contains surrounding whitespace")
|
return address, "", errors.New("recipient address is empty or contains surrounding whitespace")
|
||||||
|
|||||||
@ -1,6 +1,11 @@
|
|||||||
package validation
|
package validation
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"errors"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ErrNotificationRecipient = errors.New("notification address does not accept mail")
|
||||||
|
|
||||||
// 加号不属于可注册账号字符,保留地址不会占用普通用户的邮箱。
|
// 加号不属于可注册账号字符,保留地址不会占用普通用户的邮箱。
|
||||||
const NotificationLocalPart = "notification+system"
|
const NotificationLocalPart = "notification+system"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user