Documentation
¶
Overview ¶
Package mailgun implements mail.Mailer against Mailgun's HTTP API (https://documentation.mailgun.com/en/latest/api-sending.html).
Compared to the SMTP transport, the HTTP driver is friendlier to platforms that block outbound port 25/465/587 (Heroku, App Engine, Cloud Run, certain corporate networks) and gives Mailgun-specific affordances like tags, custom variables, and SMTP-suppression- list bypass via `v:`-headers.
Usage:
m := mailgun.New(mailgun.Config{
Domain: "mg.example.com",
APIKey: os.Getenv("MAILGUN_KEY"),
From: "noreply@example.com",
})
err := m.Send(ctx, mail.NewMessage().
To("user@example.com").
Subject("Hi").
HTML("<b>hello</b>").
Build())
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Domain is the sending domain registered with Mailgun
// (e.g. "mg.example.com").
Domain string
// APIKey is the private API key.
APIKey string
// From is the default From address used when Message.From is empty.
From string
// Region defaults to RegionUS when unset.
Region Region
// HTTPClient is the http.Client used for requests. Default has a
// 30s timeout.
HTTPClient *http.Client
}
Config holds the Mailgun API credentials.
Click to show internal directories.
Click to hide internal directories.