Do not use plainAuth when no user or password. Fixes #3320

This commit is contained in:
Yonas Yanfa 2024-09-18 20:52:40 -04:00 committed by GitHub
commit b0bcc1d2d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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