Decorators
Preview
Write email previews to disk instead of delivering them.
Write email previews to disk instead of delivering them.
Use this when you want a local .eml or HTML file for the welcome email without a mail server.
The one rule
Preview is for development, not delivery.
Quick start
import { createMailer } from "sently/mailer";
import { PreviewTransport } from "sently/transports/preview";
const transport = new PreviewTransport({ outDir: ".emails", open: true });
const mailer = await createMailer({ transport });await mailer.send({
from: "dev@example.com",
to: "you@example.com",
subject: "Welcome",
text: "Thanks for joining.",
});Files land under outDir (default ./.emails). With open: true, the OS opens the written file.
Configuration
| Option | Type | Default | Meaning |
|---|---|---|---|
outDir | string | "./.emails" | Directory for preview files |
open | boolean | false | Open the file after write |
format | "eml" | "html" | "eml" | Full MIME or HTML body only |
provider is "preview". verify() always succeeds.
For a real SMTP catcher with a web UI, use Mailpit or Inbucket instead.
Troubleshooting
No. PreviewTransport is the delivery transport — it writes to disk and does not call a provider.
Check outDir (default ./.emails). The console logs [sently preview] Written: … on each send.
Learn more
- Mailpit — local SMTP catcher with inbox API
- Inbucket — local SMTP catcher with mailbox REST API
- Email channel —
createMailercontract