Merge branch 'main' into test_close_on_nil

This commit is contained in:
Winni Neessen 2024-11-06 10:52:32 +01:00
commit 03e53cbabc
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -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 {