modules/mail/resend
Package resend sends email with Resend (https://resend.com) through its HTTP API (ADR-0025, ADR-0037).
sender, err := resend.New(cfg.ResendAPIKey)
The API key is a secret from the environment (RESEND_API_KEY). Sender names and addresses are chosen per message; apps fill them from runtime settings with mail.WithDefaults.
Refusals that retrying can't fix (invalid messages, unverified sender domains) wrap mail.ErrRejected. Rate limits, outages and an invalid API key (fixable by an operator) are temporary. Each message's idempotency key is sent as Resend's Idempotency-Key, so a retried job never sends twice.
Stability: pre-1.0 (ADR-0015).
Constants#
const DefaultBaseURL, …#
const (
DefaultBaseURL = "https://api.resend.com"
DefaultTimeout = 30 * time.Second
)Defaults.
Types#
type Option#
type Option interface {
// contains filtered or unexported methods
}An Option configures New.
func WithBaseURL#
func WithBaseURL(u string) OptionWithBaseURL sets the API base URL, for tests. Default: DefaultBaseURL.
func WithHTTPClient#
func WithHTTPClient(c *http.Client) OptionWithHTTPClient sets the HTTP client, for example one with a proxy. Its own timeout applies instead of WithTimeout.
func WithTimeout#
func WithTimeout(d time.Duration) OptionWithTimeout bounds each API request. Default: DefaultTimeout.
type Sender#
type Sender struct {
// contains filtered or unexported fields
}Sender delivers email through the Resend API. It is safe for concurrent use.
func New#
func New(apiKey config.Secret, opts ...Option) (*Sender, error)New returns a sender using apiKey, a Resend API key such as "re_123…".
func (*Sender) Send#
func (s *Sender) Send(ctx context.Context, m mail.Message) errorSend delivers m.