summaryrefslogtreecommitdiff
path: root/internal/email/sender.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-09-23 16:07:13 +0200
committerLibravatar GitHub <noreply@github.com>2024-09-23 16:07:13 +0200
commit5bd6ad68e6efe29a6d153ade8f9113973f9e42f5 (patch)
tree7db8b9816bd35d8d8d691ca38004afc4d67e1635 /internal/email/sender.go
parent[feature] Show info for pending replies, allow implicit accept of pending rep... (diff)
downloadgotosocial-5bd6ad68e6efe29a6d153ade8f9113973f9e42f5.tar.xz
[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>
Diffstat (limited to 'internal/email/sender.go')
-rw-r--r--internal/email/sender.go23
1 files changed, 16 insertions, 7 deletions
diff --git a/internal/email/sender.go b/internal/email/sender.go
index 9db918f8a..2bcc6086f 100644
--- a/internal/email/sender.go
+++ b/internal/email/sender.go
@@ -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