[server] Make sender email configurable
This commit is contained in:
parent
170e0b3e60
commit
321f97cdae
|
@ -180,6 +180,9 @@ smtp:
|
||||||
port:
|
port:
|
||||||
username:
|
username:
|
||||||
password:
|
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)
|
# Zoho Zeptomail config (optional)
|
||||||
#
|
#
|
||||||
|
|
|
@ -38,6 +38,7 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject s
|
||||||
smtpPort := viper.GetString("smtp.port")
|
smtpPort := viper.GetString("smtp.port")
|
||||||
smtpUsername := viper.GetString("smtp.username")
|
smtpUsername := viper.GetString("smtp.username")
|
||||||
smtpPassword := viper.GetString("smtp.password")
|
smtpPassword := viper.GetString("smtp.password")
|
||||||
|
smtpEmail := viper.GetString("smtp.email")
|
||||||
|
|
||||||
var emailMessage string
|
var emailMessage string
|
||||||
|
|
||||||
|
@ -50,6 +51,11 @@ func sendViaSMTP(toEmails []string, fromName string, fromEmail string, subject s
|
||||||
emailAddresses += email
|
emailAddresses += email
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If an sender email is provided use it instead of the fromEmail.
|
||||||
|
if smtpEmail != "" {
|
||||||
|
fromEmail = smtpEmail
|
||||||
|
}
|
||||||
|
|
||||||
header := "From: " + fromName + " <" + fromEmail + ">\n" +
|
header := "From: " + fromName + " <" + fromEmail + ">\n" +
|
||||||
"To: " + emailAddresses + "\n" +
|
"To: " + emailAddresses + "\n" +
|
||||||
"Subject: " + subject + "\n" +
|
"Subject: " + subject + "\n" +
|
||||||
|
|
Loading…
Reference in a new issue