Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[server] Optional SMTP authentication

Tobias Genanntd25420c86762
diff --git a/server/pkg/utils/email/email.go b/server/pkg/utils/email/email.go
index 5666aed556..9586f5451e 100644
--- a/server/pkg/utils/email/email.go
+++ b/server/pkg/utils/email/email.go
@@ -47,6 +47,10 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject s
smtpEmail := viper.GetString("smtp.email")
var emailMessage string
+ var auth smtp.Auth = nil
+ if smtpUsername != "" && smtpPassword != "" {
+ auth = smtp.PlainAuth("", smtpUsername, smtpPassword, smtpServer)
+ }
// Construct 'emailAddresses' with comma-separated email addresses
var emailAddresses string
@@ -94,7 +98,6 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject s
// Send the email to each recipient
for _, toEmail := range toEmails {
- auth := smtp.PlainAuth("", smtpUsername, smtpPassword, smtpServer)
err := smtp.SendMail(smtpServer+":"+smtpPort, auth, fromEmail, []string{toEmail}, []byte(emailMessage))
if err != nil {
errMsg := err.Error()