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