From 6b84246544fbb3f427cf5951c85f32af152548ec Mon Sep 17 00:00:00 2001 From: hxdmp <130185916+hxdmp@users.noreply.github.com> Date: Thu, 5 Oct 2023 17:44:17 +0200 Subject: [PATCH] fix #15: correctly parse esmtp args on MAIL and RCPT --- session.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/session.go b/session.go index de64054..f519471 100644 --- a/session.go +++ b/session.go @@ -211,7 +211,10 @@ func (m *serverSession) Process(msg *wire.Message) (*Response, error) { m.macros.DelStageAndAbove(StageRcpt) from := wire.ReadCString(msg.Data) msg.Data = msg.Data[len(from)+1:] - esmtpArgs := wire.ReadCString(msg.Data) + + // the rest of the data are ESMTP arguments, separated by a zero byte. + esmtpArgs := strings.Join(wire.DecodeCStrings(msg.Data), " ") + return m.backend.MailFrom(RemoveAngle(from), esmtpArgs, newModifier(m, true)) case wire.CodeRcpt: @@ -221,7 +224,10 @@ func (m *serverSession) Process(msg *wire.Message) (*Response, error) { m.macros.DelStageAndAbove(StageData) to := wire.ReadCString(msg.Data) msg.Data = msg.Data[len(to)+1:] - esmtpArgs := wire.ReadCString(msg.Data) + + // the rest of the data are ESMTP arguments, separated by a zero byte. + esmtpArgs := strings.Join(wire.DecodeCStrings(msg.Data), " ") + return m.backend.RcptTo(RemoveAngle(to), esmtpArgs, newModifier(m, true)) case wire.CodeData: