Răsfoiți Sursa

add error log

jinnrry 2 ani în urmă
părinte
comite
b1fdad8c3b
2 a modificat fișierele cu 17 adăugiri și 2 ștergeri
  1. 1 1
      server/config/config.go
  2. 16 1
      server/utils/send/send.go

+ 1 - 1
server/config/config.go

@@ -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"

+ 16 - 1
server/utils/send/send.go

@@ -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)
+								}
 							}
 						}
 					}