Skip to content

Commit

Permalink
Make MAILGUN_URL required field and update README (#12)
Browse files Browse the repository at this point in the history
Since there's no handling for optionality of MAILGUN_URL

---------

Signed-off-by: Igor Shishkin <me@teran.dev>
  • Loading branch information
teran authored Jun 13, 2024
1 parent 8cfe841 commit c5d11b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ docker run -it \
-e RELAY_MAX_RECIPIENTS=50 \
ghcr.io/teran/relay:latest
```
RELAY_MAILGUN_URL is an API URL:
* `https://api.eu.mailgun.net/v3` for EU
* `https://api.mailgun.net/v3` for US
8 changes: 4 additions & 4 deletions cmd/relay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type config struct {
AuthDisabled bool `envconfig:"AUTH_DISABLED"`
Domain string `envconfig:"DOMAIN" required:"true"`
MailgunAPIKey string `envconfig:"MAILGUN_API_KEY" required:"true"`
MailgunURL string `envconfig:"MAILGUN_URL"`
MailgunURL string `envconfig:"MAILGUN_URL" required:"true"`
MaxMessageBytes int64 `default:"1048576" envconfig:"MAX_MESSAGE_BYTES"`
MaxRecipients int `default:"50" envconfig:"MAX_RECIPIENTS"`
MetricsAddr string `envconfig:"METRICS_ADDR" default:":8081" `
Expand All @@ -51,10 +51,10 @@ func main() {
"build_timestamp": buildTimestamp,
}).Infof("initializing application")

mg := mg.NewMailgun(cfg.Domain, cfg.MailgunAPIKey)
mg.SetAPIBase(cfg.MailgunURL)
mgCli := mg.NewMailgun(cfg.Domain, cfg.MailgunAPIKey)
mgCli.SetAPIBase(cfg.MailgunURL)

dr := mailgun.New(mg)
dr := mailgun.New(mgCli)
be := smtpWrapper.NewBackend(ctx, dr)

s := smtp.NewServer(be)
Expand Down

0 comments on commit c5d11b7

Please sign in to comment.