From bb4720dbf80f6b85109cb4ab280e5a48b94b2dae Mon Sep 17 00:00:00 2001 From: kayrus Date: Fri, 3 Jun 2022 16:15:11 +0200 Subject: [PATCH] Handle custom responses for Mail and Rcpt methods --- conn.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/conn.go b/conn.go index cc0d93b..8e7015a 100644 --- a/conn.go +++ b/conn.go @@ -400,6 +400,9 @@ func (c *Conn) handleMail(arg string) { if err := c.Session().Mail(from, opts); err != nil { if smtpErr, ok := err.(*SMTPError); ok { c.WriteResponse(smtpErr.Code, smtpErr.EnhancedCode, smtpErr.Message) + if smtpErr.Code == 250 { + c.fromReceived = true + } return } c.WriteResponse(451, EnhancedCode{4, 0, 0}, err.Error()) @@ -488,6 +491,9 @@ func (c *Conn) handleRcpt(arg string) { if err := c.Session().Rcpt(recipient); err != nil { if smtpErr, ok := err.(*SMTPError); ok { c.WriteResponse(smtpErr.Code, smtpErr.EnhancedCode, smtpErr.Message) + if smtpErr.Code == 250 { + c.recipients = append(c.recipients, recipient) + } return } c.WriteResponse(451, EnhancedCode{4, 0, 0}, err.Error())