From ca663d874bd8d274a3ba7d318dca0377d7522a12 Mon Sep 17 00:00:00 2001 From: Asaf Gartner Date: Sun, 18 Sep 2022 22:23:36 +0300 Subject: [PATCH] Allow separate mailer account and From address --- src/config/config.go.example | 3 ++- src/config/types.go | 13 +++++++------ src/email/email.go | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/config/config.go.example b/src/config/config.go.example index ce5e570f..aafc5b54 100644 --- a/src/config/config.go.example +++ b/src/config/config.go.example @@ -35,8 +35,9 @@ var Config = HMNConfig{ ServerAddress: "smtp.example.com", ServerPort: 587, FromAddress: "noreply@example.com", - FromAddressPassword: "", FromName: "Handmade Network Team", + MailerUsername: "actualuser@example.com", + MailerPassword: "", ForceToAddress: "localdev@example.com", // NOTE(asaf): If this is not empty, all emails will be sent to this address. }, diff --git a/src/config/types.go b/src/config/types.go index c67a8961..6ca93eac 100644 --- a/src/config/types.go +++ b/src/config/types.go @@ -60,12 +60,13 @@ type DigitalOceanConfig struct { } type EmailConfig struct { - ServerAddress string - ServerPort int - FromAddress string - FromAddressPassword string - FromName string - ForceToAddress string + ServerAddress string + ServerPort int + FromAddress string + MailerUsername string + MailerPassword string + FromName string + ForceToAddress string } type DiscordConfig struct { diff --git a/src/email/email.go b/src/email/email.go index 36d3c78a..e11f8543 100644 --- a/src/email/email.go +++ b/src/email/email.go @@ -124,7 +124,7 @@ func sendMail(toAddress, toName, subject, contentHtml string) error { ) return smtp.SendMail( fmt.Sprintf("%s:%d", config.Config.Email.ServerAddress, config.Config.Email.ServerPort), - smtp.PlainAuth("", config.Config.Email.FromAddress, config.Config.Email.FromAddressPassword, config.Config.Email.ServerAddress), + smtp.PlainAuth("", config.Config.Email.MailerUsername, config.Config.Email.MailerPassword, config.Config.Email.ServerAddress), config.Config.Email.FromAddress, []string{toAddress}, contents,