From b0bcc1d2d7e784b21de806a56af00ec2df0aa4dd Mon Sep 17 00:00:00 2001 From: Yonas Yanfa Date: Wed, 18 Sep 2024 20:52:40 -0400 Subject: [PATCH] Do not use plainAuth when no user or password. Fixes #3320 --- internal/email/sender.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/email/sender.go b/internal/email/sender.go index 9db918f8a..412f55c3f 100644 --- a/internal/email/sender.go +++ b/internal/email/sender.go @@ -77,11 +77,18 @@ func NewSender() (Sender, error) { port := config.GetSMTPPort() from := config.GetSMTPFrom() msgIDHost := config.GetHost() + var smtpAuth smtp.Auth + + if (username == "" || password == "") { + smtpAuth = nil + } else { + smtpAuth = smtp.PlainAuth("", username, password, host) + } return &sender{ hostAddress: fmt.Sprintf("%s:%d", host, port), from: from, - auth: smtp.PlainAuth("", username, password, host), + auth: smtpAuth, msgIDHost: msgIDHost, template: t, }, nil