From bebf8bc6cea097b6b77302e222ea23bfbf24a092 Mon Sep 17 00:00:00 2001 From: Jinnrry <19919556+Jinnrry@users.noreply.github.com> Date: Sat, 25 May 2024 23:22:24 +0800 Subject: [PATCH] V2.4.8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加根路径解析记录 * 修复139邮箱发件错误 --------- Co-authored-by: jinnrry --- server/go.mod | 2 +- server/services/setup/dns.go | 1 + server/utils/send/send.go | 3 ++- server/utils/smtp/smtp.go | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/go.mod b/server/go.mod index ffe9c9e..4673256 100644 --- a/server/go.mod +++ b/server/go.mod @@ -19,6 +19,7 @@ require ( golang.org/x/crypto v0.22.0 golang.org/x/text v0.14.0 modernc.org/sqlite v1.29.6 + xorm.io/builder v0.3.13 xorm.io/xorm v1.3.9 ) @@ -50,5 +51,4 @@ require ( modernc.org/memory v1.8.0 // indirect modernc.org/strutil v1.2.0 // indirect modernc.org/token v1.1.0 // indirect - xorm.io/builder v0.3.13 // indirect ) diff --git a/server/services/setup/dns.go b/server/services/setup/dns.go index f3cd6e2..78fa882 100644 --- a/server/services/setup/dns.go +++ b/server/services/setup/dns.go @@ -26,6 +26,7 @@ func GetDNSSettings(ctx *context.Context) ([]*DNSItem, error) { ret := []*DNSItem{ {Type: "A", Host: "smtp", Value: ip.GetIp(), TTL: 3600, Tips: i18n.GetText(ctx.Lang, "ip_taps")}, {Type: "A", Host: "pop", Value: ip.GetIp(), TTL: 3600, Tips: i18n.GetText(ctx.Lang, "ip_taps")}, + {Type: "A", Host: "-", Value: ip.GetIp(), TTL: 3600, Tips: i18n.GetText(ctx.Lang, "ip_taps")}, {Type: "MX", Host: "-", Value: fmt.Sprintf("smtp.%s", configData.Domain), TTL: 3600}, {Type: "TXT", Host: "-", Value: "v=spf1 a mx ~all", TTL: 3600}, {Type: "TXT", Host: "default._domainkey", Value: auth.DkimGen(), TTL: 3600}, diff --git a/server/utils/send/send.go b/server/utils/send/send.go index 678101c..ee156d0 100644 --- a/server/utils/send/send.go +++ b/server/utils/send/send.go @@ -174,7 +174,8 @@ func Send(ctx *context.Context, e *parsemail.Email) (error, map[string]error) { // 使用其他方式发送 if err != nil { - if errors.Is(err, smtp.NoSupportSTARTTLSError) { + // EOF 表示未知错误,此时降级为非tls连接发送(目前仅139邮箱有这个问题) + if errors.Is(err, smtp.NoSupportSTARTTLSError) || err.Error() == "EOF" { err = smtp.SendMailWithTls("", domain.mxHost+":465", nil, e.From.EmailAddress, buildAddress(tos), b) if err != nil { log.WithContext(ctx).Warnf("Unsafe! %s Server Not Support SMTPS & STARTTLS", domain.domain) diff --git a/server/utils/smtp/smtp.go b/server/utils/smtp/smtp.go index b248097..36a9a6d 100644 --- a/server/utils/smtp/smtp.go +++ b/server/utils/smtp/smtp.go @@ -34,6 +34,7 @@ import ( ) var NoSupportSTARTTLSError = errors.New("smtp: server doesn't support STARTTLS") +var EOFError = errors.New("EOF") // A Client represents a client connection to an SMTP server. type Client struct {