Skip to content

Commit

Permalink
[server] Make sender email configurable (#1696)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnukvmd committed May 12, 2024
2 parents 170e0b3 + 321f97c commit e96c9dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/configurations/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#
Expand Down
6 changes: 6 additions & 0 deletions server/pkg/utils/email/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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" +
Expand Down

0 comments on commit e96c9dd

Please sign in to comment.