From df3d2fd8d4536743cd37854d6b5d3a83d35cf79c Mon Sep 17 00:00:00 2001 From: cyrilc Date: Tue, 9 Aug 2022 17:46:25 +0200 Subject: [PATCH] Set connection deadline before using it --- smtp.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/smtp.go b/smtp.go index c56a65b..91b58d4 100644 --- a/smtp.go +++ b/smtp.go @@ -88,15 +88,15 @@ func (d *Dialer) Dial() (SendCloser, error) { conn = tlsClient(conn, d.tlsConfig()) } + if d.Timeout > 0 { + conn.SetDeadline(time.Now().Add(d.Timeout)) + } + c, err := smtpNewClient(conn, d.Host) if err != nil { return nil, err } - if d.Timeout > 0 { - conn.SetDeadline(time.Now().Add(d.Timeout)) - } - if d.LocalName != "" { if err := c.Hello(d.LocalName); err != nil { return nil, err