From ae407fffcaf76c741867cd64288cc4c402a348ce Mon Sep 17 00:00:00 2001 From: xiecang Date: Wed, 16 Nov 2022 12:29:20 +0800 Subject: [PATCH] fix: ignore error "starttls command has been already sent" --- services/mail/smtp.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/mail/smtp.go b/services/mail/smtp.go index 87fe2b6..4888e88 100644 --- a/services/mail/smtp.go +++ b/services/mail/smtp.go @@ -42,7 +42,12 @@ func (s *SMTPSendingService) Send(mail *models.Mail) error { if ok, _ := c.Extension("STARTTLS"); ok { if err = c.StartTLS(nil); err != nil { - return err + errCode := err.(*smtp.SMTPError).Code + if errCode == 503 { + // TLS already active + } else { + return err + } } } if s.auth != nil {