Documentation
¶
Overview ¶
Package postmark sends email through Postmark.
Choosing it commits a deployment to a Postmark server token, which is per-server rather than per-account and therefore selects which stream the mail is billed and reported against. Config.BaseURL overrides the API host, which is what points the package at an httptest server.
The context does not reach the wire ¶
This is the one emailer here whose vendor client takes no context. SendEmail accepts one, and uses it for the span and for the metrics it records, but the HTTP call underneath is issued without it: cancelling the context or letting its deadline lapse does not abort a send in flight. What bounds a send is the timeout on the *http.Client the caller supplied. Every other provider in this family passes the context through to the request.
What one send is ¶
SendEmail delivers one HTML message to one recipient and returns when Postmark has answered, recording the returned message ID on the span. It is synchronous and does not retry; a failed send scores the circuit breaker, and while that breaker is open every call returns circuitbreaking.ErrCircuitBroken. Addresses are rendered through email.FormatAddress, which quotes the display name so a comma in it cannot inject recipients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilConfig indicates a nil config was provided. ErrNilConfig = platformerrors.New("postmark config is nil") // ErrEmptyServerToken indicates an empty server token was provided. ErrEmptyServerToken = platformerrors.New("empty Postmark server token") // ErrNilHTTPClient indicates a nil HTTP client was provided. ErrNilHTTPClient = platformerrors.New("nil postmark HTTP client") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ServerToken string `env:"SERVER_TOKEN" json:"serverToken,omitempty" yaml:"serverToken,omitempty"`
// BaseURL overrides the API base URL (e.g. for testing with httptest).
BaseURL string `env:"BASE_URL" json:"baseURL,omitempty" yaml:"baseURL,omitempty"`
}
Config configures Postmark to send email.
type Emailer ¶
type Emailer struct {
// contains filtered or unexported fields
}
Emailer uses Postmark to send email.
func NewPostmarkEmailer ¶
func NewPostmarkEmailer(cfg *Config, client *http.Client, circuitBreaker circuitbreaking.CircuitBreaker, opts ...Option) (*Emailer, error)
NewPostmarkEmailer returns a new Postmark-backed Emailer.
type Option ¶
type Option func(*options)
Option configures the Emailer this package constructs. The zero configuration works: an absent logger logs nowhere, an absent tracer provider traces nowhere, and an absent metrics provider records nothing.
func WithMetricsProvider ¶
WithMetricsProvider attaches a metrics provider.
func WithTracerProvider ¶
WithTracerProvider attaches a tracer provider, enabling spans on every send.