mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-24 20:56:39 +00:00
[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:
parent
1ce854358d
commit
5bd6ad68e6
|
@ -71,17 +71,26 @@ func NewSender() (Sender, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
username := config.GetSMTPUsername()
|
var (
|
||||||
password := config.GetSMTPPassword()
|
username = config.GetSMTPUsername()
|
||||||
host := config.GetSMTPHost()
|
password = config.GetSMTPPassword()
|
||||||
port := config.GetSMTPPort()
|
host = config.GetSMTPHost()
|
||||||
from := config.GetSMTPFrom()
|
port = config.GetSMTPPort()
|
||||||
msgIDHost := config.GetHost()
|
from = config.GetSMTPFrom()
|
||||||
|
msgIDHost = config.GetHost()
|
||||||
|
smtpAuth smtp.Auth
|
||||||
|
)
|
||||||
|
|
||||||
|
if username == "" || password == "" {
|
||||||
|
smtpAuth = nil
|
||||||
|
} else {
|
||||||
|
smtpAuth = smtp.PlainAuth("", username, password, host)
|
||||||
|
}
|
||||||
|
|
||||||
return &sender{
|
return &sender{
|
||||||
hostAddress: fmt.Sprintf("%s:%d", host, port),
|
hostAddress: fmt.Sprintf("%s:%d", host, port),
|
||||||
from: from,
|
from: from,
|
||||||
auth: smtp.PlainAuth("", username, password, host),
|
auth: smtpAuth,
|
||||||
msgIDHost: msgIDHost,
|
msgIDHost: msgIDHost,
|
||||||
template: t,
|
template: t,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
Loading…
Reference in a new issue