From 4a69c9e9441014bd4631a5ba444b95db21d800d3 Mon Sep 17 00:00:00 2001 From: "fox.cpp" Date: Tue, 30 Jan 2024 01:24:44 +0300 Subject: [PATCH] Fix-up 7bdc981eac3ff1e83585184563949ac1171e643e --- internal/smtpconn/smtpconn.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/smtpconn/smtpconn.go b/internal/smtpconn/smtpconn.go index 4dca9575..d7b42459 100644 --- a/internal/smtpconn/smtpconn.go +++ b/internal/smtpconn/smtpconn.go @@ -172,6 +172,10 @@ func (c *C) Connect(ctx context.Context, endp config.Endpoint, starttls bool, tl c.serverName = endp.Host c.cl = cl c.conn = conn + + c.Log.DebugMsg("connected", "remote_server", c.serverName, + "local_addr", c.LocalAddr(), "remote_addr", c.RemoteAddr()) + return didTLS, nil } @@ -186,6 +190,10 @@ func (c *C) ConnectLMTP(ctx context.Context, endp config.Endpoint, starttls bool c.serverName = endp.Host c.cl = cl c.conn = conn + + c.Log.DebugMsg("connected", "remote_server", c.serverName, + "local_addr", c.LocalAddr(), "remote_addr", c.RemoteAddr()) + return didTLS, nil } @@ -221,7 +229,6 @@ func (c *C) RemoteAddr() net.Addr { } func (c *C) attemptConnect(ctx context.Context, lmtp bool, endp config.Endpoint, starttls bool, tlsConfig *tls.Config) (didTLS bool, cl *smtp.Client, conn net.Conn, err error) { - dialCtx, cancel := context.WithTimeout(ctx, c.ConnectTimeout) conn, err = c.Dialer(dialCtx, endp.Network(), endp.Address()) cancel() @@ -253,11 +260,11 @@ func (c *C) attemptConnect(ctx context.Context, lmtp bool, endp config.Endpoint, } if endp.IsTLS() || !starttls { - return endp.IsTLS(), cl, nil, nil + return endp.IsTLS(), cl, conn, nil } if ok, _ := cl.Extension("STARTTLS"); !ok { - return false, cl, nil, nil + return false, cl, conn, nil } cfg := tlsConfig.Clone() @@ -323,8 +330,6 @@ func (c *C) Mail(ctx context.Context, from string, opts smtp.MailOptions) error return c.wrapClientErr(err, c.serverName) } - c.Log.DebugMsg("connected", "remote_server", c.serverName, - "local_addr", c.LocalAddr(), "remote_addr", c.RemoteAddr()) return nil }