Skip to content

Commit ed2b490

Browse files
authored
fix: use api_external_url domain as localname (#1575)
## What kind of change does this PR introduce? * Fixes an issue where some SMTP providers reject requests when the SMTP client uses a Local Name that is identical to the SMTP Host name.
1 parent 86a79df commit ed2b490

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ require (
7272
github.com/jackc/pgx/v4 v4.18.2
7373
github.com/standard-webhooks/standard-webhooks/libraries v0.0.0-20240303152453-e0e82adf1721
7474
github.com/supabase/hibp v0.0.0-20231124125943-d225752ae869
75-
github.com/supabase/mailme v0.1.0
75+
github.com/supabase/mailme v0.2.0
7676
github.com/xeipuuv/gojsonschema v1.2.0
7777
)
7878

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ github.com/supabase/hibp v0.0.0-20231124125943-d225752ae869 h1:VDuRtwen5Z7QQ5ctu
492492
github.com/supabase/hibp v0.0.0-20231124125943-d225752ae869/go.mod h1:eHX5nlSMSnyPjUrbYzeqrA8snCe2SKyfizKjU3dkfOw=
493493
github.com/supabase/mailme v0.1.0 h1:1InJqMMPTFqZfRZ/gnsCwOc+oUWCFuxSXhlCCG6zYUo=
494494
github.com/supabase/mailme v0.1.0/go.mod h1:kWsnmPfUBZTavlXYkfJrE9unzmmRAIi/kqsxXfEWEY8=
495+
github.com/supabase/mailme v0.2.0 h1:39LHZ4+YOeqoN4MiuncPBC3JarExAa0flmokM24qHNU=
496+
github.com/supabase/mailme v0.2.0/go.mod h1:kWsnmPfUBZTavlXYkfJrE9unzmmRAIi/kqsxXfEWEY8=
495497
github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg=
496498
github.com/twmb/murmur3 v1.1.6/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
497499
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=

internal/mailer/mailer.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,22 @@ func NewMailer(globalConfig *conf.GlobalConfiguration) Mailer {
5050
mail.SetHeader("Message-ID", fmt.Sprintf("<%s@gotrue-mailer>", uuid.Must(uuid.NewV4()).String()))
5151

5252
from := mail.FormatAddress(globalConfig.SMTP.AdminEmail, globalConfig.SMTP.SenderName)
53+
u, _ := url.ParseRequestURI(globalConfig.API.ExternalURL)
5354

5455
var mailClient MailClient
5556
if globalConfig.SMTP.Host == "" {
5657
logrus.Infof("Noop mail client being used for %v", globalConfig.SiteURL)
5758
mailClient = &noopMailClient{}
5859
} else {
5960
mailClient = &mailme.Mailer{
60-
Host: globalConfig.SMTP.Host,
61-
Port: globalConfig.SMTP.Port,
62-
User: globalConfig.SMTP.User,
63-
Pass: globalConfig.SMTP.Pass,
64-
From: from,
65-
BaseURL: globalConfig.SiteURL,
66-
Logger: logrus.StandardLogger(),
61+
Host: globalConfig.SMTP.Host,
62+
Port: globalConfig.SMTP.Port,
63+
User: globalConfig.SMTP.User,
64+
Pass: globalConfig.SMTP.Pass,
65+
LocalName: u.Hostname(),
66+
From: from,
67+
BaseURL: globalConfig.SiteURL,
68+
Logger: logrus.StandardLogger(),
6769
}
6870
}
6971

0 commit comments

Comments
 (0)