From d47edac376ad1a7035acad1b01ce9a41e25d22df Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 3 Aug 2022 13:41:42 +0200 Subject: [PATCH] feat(mail): don't try to authenticate when no username and password was provided --- pkg/mail/mail.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/mail/mail.go b/pkg/mail/mail.go index 824db0876e..98ae70af56 100644 --- a/pkg/mail/mail.go +++ b/pkg/mail/mail.go @@ -48,7 +48,6 @@ func getClient() (*mail.Client, error) { } opts := []mail.Option{ - mail.WithSMTPAuth(authType), mail.WithPort(config.MailerPort.GetInt()), mail.WithTLSPolicy(tlsPolicy), //#nosec G402 @@ -58,6 +57,10 @@ func getClient() (*mail.Client, error) { }), } + if config.MailerUsername.GetString() != "" && config.MailerPassword.GetString() != "" { + opts = append(opts, mail.WithSMTPAuth(authType)) + } + if config.MailerUsername.GetString() != "" { opts = append(opts, mail.WithUsername(config.MailerUsername.GetString())) }