From 6f93552458dfbeeb5b7d1b43899eac1970260e68 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sat, 23 Dec 2023 12:05:52 +0530 Subject: [PATCH] RSET connection every time before re-using in the pool. Ref: https://github.com/knadh/listmonk/issues/1629 https://github.com/knadh/listmonk/issues/1530 https://github.com/knadh/listmonk/issues/1192 https://github.com/knadh/listmonk/issues/300 --- pool.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pool.go b/pool.go index 75b6fa3..bf547ad 100644 --- a/pool.go +++ b/pool.go @@ -262,6 +262,12 @@ func (p *Pool) returnConn(c *conn, lastErr error) (err error) { } } + // Always RSET (SMTP) the connection bfeore reusing it as some servers + // throw "sender already specified", or "commands out of sequence" errors. + if err := c.conn.Reset(); err != nil { + return err + } + select { case p.conns <- c: return nil