From 118f7b698f506a568c2528df3c0c4133b53f7d8c Mon Sep 17 00:00:00 2001 From: Nicolai Langfeldt Date: Fri, 25 Apr 2025 12:48:59 +0200 Subject: [PATCH] Do not auth unless we have something to auth with --- client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index e10adf9..4c9ff8f 100644 --- a/client.go +++ b/client.go @@ -105,14 +105,14 @@ func handshake(client *smtp.Client, config *relayConfig, tlsConfig *tls.Config) } - var auth smtp.Auth + var auth smtp.Auth = nil if config.LoginAuthType { auth = LoginAuth(config.Username, config.Password) - } else { + } else if config.Username != "" { auth = smtp.PlainAuth("", config.Username, config.Password, config.Server) } - if err := client.Auth(auth); err != nil { + if auth != nil && err := client.Auth(auth); err != nil { return errors.Wrap(err, "auth error") } return nil