Skip to content

Commit de0e889

Browse files
committed
feat: configurable mailgun apibase
1 parent 7e090b6 commit de0e889

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

backend/pkg/commons/mail/mail.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ func SendMailMailgun(to, subject, msgHtml, msgText string, attachment []types.Em
136136
utils.Config.Frontend.Mail.Mailgun.Domain,
137137
utils.Config.Frontend.Mail.Mailgun.PrivateKey,
138138
)
139+
if utils.Config.Frontend.Mail.Mailgun.UseEUAPI {
140+
mg.SetAPIBase(mailgun.APIBaseEU)
141+
}
139142

140143
// if the text part still contains html tags / entities, remove / convert them
141144
msgText = html2text.HTML2Text(msgText)
@@ -184,6 +187,10 @@ func SendTextMailMailgun(to, subject, msg string, attachment []types.EmailAttach
184187
utils.Config.Frontend.Mail.Mailgun.Domain,
185188
utils.Config.Frontend.Mail.Mailgun.PrivateKey,
186189
)
190+
if utils.Config.Frontend.Mail.Mailgun.UseEUAPI {
191+
mg.SetAPIBase(mailgun.APIBaseEU)
192+
}
193+
187194
message := mg.NewMessage(utils.Config.Frontend.Mail.Mailgun.Sender, subject, msg, to)
188195

189196
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)

backend/pkg/commons/types/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ type Config struct {
134134
Domain string `yaml:"domain" env:"DOMAIN"`
135135
PrivateKey string `yaml:"privateKey" env:"PRIVATE_KEY"`
136136
Sender string `yaml:"sender" env:"SENDER"`
137+
UseEUAPI bool `yaml:"useEUApi" envconfig:"USE_EU_API"`
137138
} `yaml:"mailgun" env:", prefix=MAILGUN_"`
138139
Contact struct {
139140
SupportEmail string `yaml:"supportEmail" env:"SUPPORT_EMAIL"`

0 commit comments

Comments
 (0)