@dokebi/mail
v0.4.7
Published
Mail for Dokebi apps: EJS templates per locale, SMTP (nodemailer, STARTTLS required) and Amazon SES v2, queued sending through @dokebi/job with sealed data, deterministic Message-IDs, a development inbox and test helpers.
Maintainers
Readme
@dokebi/mail
Mail for Dokebi apps (D-0078):
- Templates in
src/shared/mail/<name>/<locale>/(subject.ejs,html.ejs,text.ejs) with layouts, compiled once at start with the EJS engine of @dokebi/template-ejs. HTML escapes data; subjects and text do not; a subject with a line break is refused. Withouttext.ejsthe text part is made from the HTML (a tokenizer: links astext (url), lists, quotes). Helpers$url(path)and$date(value). Modules can contribute template folders; the project's win. - Transports:
smtpthrough nodemailer — STARTTLS required (465: implicit TLS), TLS 1.2 or newer, certificate verification, a connection pool, timeouts, DKIM;sesthrough the SES v2 HTTPS API with SigV4 (no AWS SDK), configuration sets and tags;log(a development inbox) andcapture(tests), both refused in production; more by name from the entry file. - Queued sending through @dokebi/job:
mail.queue(message)checks the message, encrypts itssealedvalues (links, tokens) into the job with AES-256-GCM bound to the job id, the template, the recipients and the sender (a job rewritten to other addresses is refused, never sent), and submits it; the plugin's own handler renders and sends. Without job,queueis refused — never sent synchronously instead.mail.send(message)sends at once (scripts, tests). - At-least-once delivery with duplicate suppression: the Message-ID is derived from the idempotency key (the job id); with @dokebi/redis a "sent" marker suppresses deliveries after a successful send has been recorded. A crash before that marker, a marker-store failure or concurrent sends can still produce duplicates; this is not exactly once. SMTP 5xx and other permanent failures go straight to the job's dead-letter stream; 4xx, network and TLS trouble are retried. A per-transport rate limit (shared through Redis) delays mail instead of failing it.
- Safety: strict addresses (punycode for international domains), no CR, LF or NUL in names, subjects, header values or attachment names, an allow-list of headers, senders only from
allowedFrom, bulk mail only withList-Unsubscribe(One-Click for https). Logs carry masked recipients (k***@example.com) and never a body or a sealed value. - Development and tests: a loopback-only inbox and template preview at
/_dokebi/mail(absent in production), and@dokebi/mail/testingwithoutbox,waitFor,linkIn,clearandcaptureTransport().
npx dokebi add @dokebi/mail # writes a generated secret into dokebi.yaml (dokebi-mail.secrets)Options, templates, the message shape, errors, logs, the development inbox, testing and the extension: AI.md. License: MIT.
CLI templates and local development
The catalog provides mail. The blog/API recipe asks --mail none|mailpit|smtp|ses; Mailpit prepares a local inbox and durable queue in compose.mail.yaml. SMTP/SES use settings supplied in dokebi.yaml. Install adds an editable welcome template in src/shared/mail/. Render its sample without network connections with npx dokebi mail preview welcome --locale en --json. See the AI guide for configuration, preservation and check rules.
