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

OptionTypeDefaultMeaning
outDirstring"./.emails"Directory for preview files
openbooleanfalseOpen 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

Learn more

  • Mailpit — local SMTP catcher with inbox API
  • Inbucket — local SMTP catcher with mailbox REST API
  • Email channelcreateMailer contract

Next

On this page