Add nil check for smtpClient in checkConn function

Previously, if smtpClient was nil, the checkConn function would not handle that case. This update ensures that an appropriate error is returned when smtpClient is nil, enhancing the robustness of the client connection checks.
This commit is contained in:
Winni Neessen 2024-10-24 10:44:40 +02:00
parent 5e3ebcc1a6
commit 4a8ac76636
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -1298,6 +1298,9 @@ func (c *Client) sendSingleMsg(message *Msg) error {
// - An error if there is no active connection, if the NOOP command fails, or if extending
// the deadline fails; otherwise, returns nil.
func (c *Client) checkConn() error {
if c.smtpClient == nil {
return ErrNoActiveConnection
}
if !c.smtpClient.HasConnection() {
return ErrNoActiveConnection
}