DOCS / FEATURES
Transactional email is sent from a background job through a pluggable
Mailer: Resend in production, the console in development. Handlers never
send email themselves. They enqueue a job and the worker renders
and delivers it, so you get retries with backoff, and a slow or failing
mail provider never slows down or fails a request. The code is in
api/src/email/: mailer.rs is the transport seam, templates.rs the
content, and mod.rs holds one send function per job.
Transports
Mailer is a one-method trait (send(Email)), chosen at startup by
mailer::from_config:
| Transport | When | Behaviour |
|---|---|---|
ResendMailer |
EMAIL_API_KEY is set |
POST https://api.resend.com/emails with HTML and text bodies. A non-2xx response fails the job, which retries |
ConsoleMailer |
No key | Logs recipient, subject, and the plain-text body (action links included) at info level |
RecordingMailer |
Tests | Captures emails for assertions |
With the console mailer you can click through each flow from the API's
terminal output in development (abridged, and the log line also carries
to and subject fields):
──────── email (console mailer) ────────
Hi Ada, welcome to LaunchCrate! Confirm this email address ...
Verify: http://localhost:5173/verify?token=3f9c...
─────────────────────────────────────────To use another provider (SES, Postmark, ...), implement Mailer and
select it in from_config.
[ full guide ]
The rest of this guide comes with the repo.
- The emails
- Templates
- Going live
- Watching delivery