mirror of
1
Fork 0

[bugfix/email] Don't use plainAuth when no smtp username/password provided (#3332)

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

* formatting

---------

Co-authored-by: Yonas Yanfa <yonas.y@gmail.com>
This commit is contained in:
tobi 2024-09-23 16:07:13 +02:00 committed by GitHub
parent 1ce854358d
commit 5bd6ad68e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 7 deletions

View File

@ -71,17 +71,26 @@ func NewSender() (Sender, error) {
return nil, err
}
username := config.GetSMTPUsername()
password := config.GetSMTPPassword()
host := config.GetSMTPHost()
port := config.GetSMTPPort()
from := config.GetSMTPFrom()
msgIDHost := config.GetHost()
var (
username = config.GetSMTPUsername()
password = config.GetSMTPPassword()
host = config.GetSMTPHost()
port = config.GetSMTPPort()
from = config.GetSMTPFrom()
msgIDHost = config.GetHost()
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