add error log

This commit is contained in:
jinnrry 2023-09-08 21:18:38 +08:00
parent a981222bae
commit b1fdad8c3b
2 changed files with 17 additions and 2 deletions

View File

@ -38,7 +38,7 @@ type Config struct {
//go:embed tables/*
var tableConfig embed.FS
const Version = "2.2.0"
const Version = "2.2.1"
const DBTypeMySQL = "mysql"
const DBTypeSQLite = "sqlite"

View File

@ -69,8 +69,12 @@ func Forward(ctx *context.Context, e *parsemail.Email, forwardAddress string) er
// 先使用smtps协议尝试
err := smtp.SendMailWithTls("", domain.mxHost+":465", nil, e.From.EmailAddress, buildAddress(tos), b)
if err != nil {
log.WithContext(ctx).Errorf("SMTPS Send Error! Error:%+v", err)
// smtps发送失败,尝试smtp
err = smtp.SendMail("", domain.mxHost+":25", nil, e.From.EmailAddress, buildAddress(tos), b)
if err != nil {
log.WithContext(ctx).Errorf("SMTP Send Error! Error:%+v", err)
}
}
// 重新选取证书域名
@ -82,9 +86,12 @@ func Forward(ctx *context.Context, e *parsemail.Email, forwardAddress string) er
// 先使用smtps协议尝试
err = smtp.SendMailWithTls(domainMatch(domain.domain, certificateHostName), domain.mxHost+":465", nil, e.From.EmailAddress, buildAddress(tos), b)
if err != nil {
log.Infoln(err)
log.WithContext(ctx).Errorf("SMTPS Send Error! Error:%+v", err)
// smtps发送失败,尝试smtp
err = smtp.SendMail(domainMatch(domain.domain, certificateHostName), domain.mxHost+":25", nil, e.From.EmailAddress, buildAddress(tos), b)
if err != nil {
log.WithContext(ctx).Errorf("SMTP Send Error! Error:%+v", err)
}
}
}
}
@ -156,8 +163,12 @@ func Send(ctx *context.Context, e *parsemail.Email) (error, map[string]error) {
// 先使用smtps协议尝试
err := smtp.SendMailWithTls("", domain.mxHost+":465", nil, e.From.EmailAddress, buildAddress(tos), b)
if err != nil {
log.WithContext(ctx).Errorf("SMTPS Send Error! Error:%+v", err)
// smtps发送失败,尝试smtp
err = smtp.SendMail("", domain.mxHost+":25", nil, e.From.EmailAddress, buildAddress(tos), b)
if err != nil {
log.WithContext(ctx).Errorf("SMTP Send Error! Error:%+v", err)
}
}
// 重新选取证书域名
@ -169,8 +180,12 @@ func Send(ctx *context.Context, e *parsemail.Email) (error, map[string]error) {
// 先使用smtps协议尝试
err = smtp.SendMailWithTls(domainMatch(domain.domain, certificateHostName), domain.mxHost+":465", nil, e.From.EmailAddress, buildAddress(tos), b)
if err != nil {
log.WithContext(ctx).Errorf("SMTPS Send Error! Error:%+v", err)
// smtps发送失败,尝试smtp
err = smtp.SendMail(domainMatch(domain.domain, certificateHostName), domain.mxHost+":25", nil, e.From.EmailAddress, buildAddress(tos), b)
if err != nil {
log.WithContext(ctx).Errorf("SMTP Send Error! Error:%+v", err)
}
}
}
}