Documentation
¶
Overview ¶
Package mailer defines a backend-agnostic transactional email interface.
One Sender interface, multiple backends:
memory — captures messages in-process (tests, dev)
smtp — any SMTP server (net/smtp); the portable standard
brevo — Brevo HTTP API; free transactional path that accepts a
single email-verified sender without owning a domain
The library never logs and never sends partial output: a Send either returns nil or an error. Callers own logging and retry policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidMessage is returned by Send when m fails Validate. ErrInvalidMessage = errors.New("mailer: invalid message") // ErrSendFailed wraps a backend delivery failure. Backends wrap this // with a status code or transport error — never the upstream response // body, which can leak credentials. ErrSendFailed = errors.New("mailer: send failed") )
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct {
From Address
To []Address
Subject string
Text string // plain-text body
HTML string // optional HTML body
}
Message is a single transactional email. At least one of Text or HTML must be set; a backend sends multipart/alternative when both are present.
func (Message) Validate ¶
Validate reports whether m is well-formed enough to attempt delivery. Backends call this before doing any network work and return its result directly — every non-nil error wraps ErrInvalidMessage, so callers can errors.Is against that sentinel while still seeing the specific reason. This is the boundary check; backends trust the message past this point.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package brevo is a Sender backed by the Brevo (formerly Sendinblue) transactional email HTTP API.
|
Package brevo is a Sender backed by the Brevo (formerly Sendinblue) transactional email HTTP API. |
|
cmd
|
|
|
sendmail
command
Command sendmail sends one message through a mailer backend chosen at runtime.
|
Command sendmail sends one message through a mailer backend chosen at runtime. |
|
Package memory is an in-process Sender for tests and local dev.
|
Package memory is an in-process Sender for tests and local dev. |
|
Package smtp is a Sender backed by any SMTP server (net/smtp).
|
Package smtp is a Sender backed by any SMTP server (net/smtp). |