[server] Make sender email configurable (#1696)

Ref:
https://github.com/ente-io/ente/discussions/1582#discussioncomment-9404061
This commit is contained in:
Vishnu Mohandas 2024-05-12 16:06:17 +05:30 committed by GitHub
commit e96c9dd2a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -180,6 +180,9 @@ smtp:
port:
username:
password:
# The email address from which to send the email. Set this to an email
# address whose credentials you're providing.
email:
# Zoho Zeptomail config (optional)
#

View file

@ -38,6 +38,7 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject s
smtpPort := viper.GetString("smtp.port")
smtpUsername := viper.GetString("smtp.username")
smtpPassword := viper.GetString("smtp.password")
smtpEmail := viper.GetString("smtp.email")
var emailMessage string
@ -50,6 +51,11 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject s
emailAddresses += email
}
// If an sender email is provided use it instead of the fromEmail.
if smtpEmail != "" {
fromEmail = smtpEmail
}
header := "From: " + fromName + " <" + fromEmail + ">\n" +
"To: " + emailAddresses + "\n" +
"Subject: " + subject + "\n" +