Spec: Written ahead of the package. Not in 7.0.0-alpha.0: email7.0.0-alpha.0
Six kinds of mail a product sends, drawn from the Product record and one event, each in the product's Theme with a plain-text twin.
email(kind, product, event) returns one message: { subject, html, text }. The HTML is a table layout with its styles inline, in the product's Theme, because mail clients drop a stylesheet. The text is the same message without markup.
What it renders
| Kind | Sent when | Reads from the event |
|---|---|---|
welcome | A key is issued | The key prefix and the first call |
usage | A usage threshold is crossed | The calls used and the plan's limit |
limit | The plan's limit is reached | The limit, the date it resets and the next plan |
webhook | A webhook endpoint keeps failing | The endpoint, the last status and the retry count |
plan | The plan changes | The old and the new plan |
billing | A charge fails | The amount and the payment page |
Every kind reads the product's name, Theme and dashboard address from the Product record, so no message names a plan the pricing page does not.
How it maps
startupbuilder.dev's Template renders "a Message, Document, or Page". Each kind of mail here is the Message rendering of one Template, filled from the event's records.