From 8c4eb62360af707726f414ce9ea824e1dbda9de9 Mon Sep 17 00:00:00 2001 From: Alysson Ribeiro <15274059+sonalys@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:20:59 +0100 Subject: [PATCH] Fix(close): Access to nil variable causes panic --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index abb90f4..fbb28f5 100644 --- a/client.go +++ b/client.go @@ -996,7 +996,7 @@ func (c *Client) DialWithContext(dialCtx context.Context) error { // Returns: // - An error if the disconnection fails; otherwise, returns nil. func (c *Client) Close() error { - if !c.smtpClient.HasConnection() { + if c.smtpClient == nil || !c.smtpClient.HasConnection() { return nil } if err := c.smtpClient.Quit(); err != nil {