From a6bcd26be988a1ea716e21079695e9ff201acb81 Mon Sep 17 00:00:00 2001 From: Stojan Dimitrovski Date: Mon, 14 Oct 2024 11:05:00 +0200 Subject: [PATCH] fix: email header setting no longer misleading --- internal/conf/configuration.go | 7 +++++++ internal/mailer/mailer.go | 13 +------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/internal/conf/configuration.go b/internal/conf/configuration.go index 4db5e2ddce..8c7dcae1ab 100644 --- a/internal/conf/configuration.go +++ b/internal/conf/configuration.go @@ -18,6 +18,7 @@ import ( "github.com/joho/godotenv" "github.com/kelseyhightower/envconfig" "github.com/lestrrat-go/jwx/v2/jwk" + "gopkg.in/gomail.v2" ) const defaultMinPasswordLength int = 6 @@ -353,6 +354,12 @@ func (c *SMTPConfiguration) Validate() error { return nil } +func (c *SMTPConfiguration) FromAddress() string { + mail := gomail.NewMessage() + + return mail.FormatAddress(c.AdminEmail, c.SenderName) +} + type MailerConfiguration struct { Autoconfirm bool `json:"autoconfirm"` AllowUnverifiedEmailSignIns bool `json:"allow_unverified_email_sign_ins" split_words:"true" default:"false"` diff --git a/internal/mailer/mailer.go b/internal/mailer/mailer.go index 142eb1a6ba..5c8a90a1fb 100644 --- a/internal/mailer/mailer.go +++ b/internal/mailer/mailer.go @@ -5,11 +5,9 @@ import ( "net/http" "net/url" - "github.com/gofrs/uuid" "github.com/sirupsen/logrus" "github.com/supabase/auth/internal/conf" "github.com/supabase/auth/internal/models" - "gopkg.in/gomail.v2" ) // Mailer defines the interface a mailer must implement. @@ -42,16 +40,7 @@ type EmailData struct { // NewMailer returns a new gotrue mailer func NewMailer(globalConfig *conf.GlobalConfiguration) Mailer { - mail := gomail.NewMessage() - - mail.SetHeaders(map[string][]string{ - // Make the emails explicitly set to be HTML formatted (to cover older email clients) - "Content-Type": {"text/html; charset=utf-8"}, - // so that messages are not grouped under each other - "Message-ID": {fmt.Sprintf("<%s@gotrue-mailer>", uuid.Must(uuid.NewV4()).String())}, - }) - - from := mail.FormatAddress(globalConfig.SMTP.AdminEmail, globalConfig.SMTP.SenderName) + from := globalConfig.SMTP.FromAddress() u, _ := url.ParseRequestURI(globalConfig.API.ExternalURL) var mailClient MailClient