Documentation
¶
Overview ¶
Package systemmail sends ReputeCast's own mail (password resets, email changes, team invitations, notifications, double opt-in confirmations, test messages) through the workspace's System-stream route, whose fallback takes over when the provider is down or refuses the message. It implements mailer.Sender (App.Mail).
Messages without a workspace (a password reset, an email change) go through the recipient's first workspace, by membership date, that has a usable System route, and otherwise through the instance's oldest workspace with one. The From address is the workspace's System sender, else its default sender, else its first sender.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDemoProvider = errors.New("this is a sample provider from the demo data and can't send real mail; connect a sending provider and route the System stream to it")
ErrDemoProvider is returned outside development for the demo's sample providers: they have no real account behind them.
var ErrNoSender error = noSenderError{}
ErrNoSender means the workspace has no sender identity to send from. It counts as mailer.ErrNoSystemProvider, so callers fall back the way they do without a System provider (copy a link, the CLI command).
Functions ¶
func HTMLToText ¶
HTMLToText is a rough plain-text version of an HTML fragment: links keep their URL, paragraphs become lines.
func TextToHTML ¶
TextToHTML turns plain text into paragraphs with clickable links in the brand's colour.
Types ¶
type Brand ¶
Brand is who a system message comes from: ReputeCast (the instance) for messages to team members, the publisher for messages to subscribers.
type Deliverer ¶
type Deliverer struct {
Pool *pgxpool.Pool
Q *store.Queries
Factory *manage.Factory
// ApplyEvent records a normalized event through the ingest pipeline
// (message status, provider stats, event log).
ApplyEvent func(ctx context.Context, tx pgx.Tx, p store.Provider, ev providers.Event) error
// DevSMTP is the development mail catcher ("localhost:1025"); empty
// outside development.
DevSMTP string
Log *slog.Logger
Now func() time.Time
}
Deliverer sends one message through a connected provider and records it like any other send: a messages row (stream system, with its kind), the provider's call statistics and, when the provider reports no delivery events of its own (SMTP), the delivered event inferred from its 250 reply.
Demo providers (providers.config "demo": true) never reach a provider API: in development their mail goes to DevSMTP (Mailpit) and is recorded as delivered by that provider; elsewhere Send refuses with ErrDemoProvider.
type Delivery ¶
type Delivery struct {
ProviderMessageID string
QueuedAt time.Time
SentAt time.Time
// Via names where a demo provider's mail went ("Mailpit").
Via string
}
Delivery is the outcome of one message.
type Mailer ¶
type Mailer struct {
Q *store.Queries
Deliver *Deliverer
// Instance returns the instance name and public URL for the brand.
Instance func(ctx context.Context) (name, publicURL string)
Log *slog.Logger
Now func() time.Time
// contains filtered or unexported fields
}
Mailer is the System-stream mailer.
func (*Mailer) Forget ¶
func (m *Mailer) Forget()
Forget drops the cached availability (after routing or providers changed).
func (*Mailer) SendSystem ¶
SendSystem implements mailer.Sender: it returns the name of the provider that accepted the message.
func (*Mailer) SenderEmail ¶
SenderEmail is the From address of a workspace's system mail (the double opt-in confirmation, for one): "" when it has none or it can't be read.
type Rendered ¶
Rendered is a message ready for a provider.