Transports

Mailpit

Catch outbound email in a local Mailpit instance during development.

Catch outbound email in a local Mailpit instance while you develop. Use it for the welcome email or password-reset flow before you point at a production provider.

The one rule

Use Mailpit only in development — swap to a production transport before you deploy. Vendor extras stay on the MailpitTransport instance — never on createMailer.

Quick start

Start Mailpit (SMTP 1025, UI 8025):

docker run -d --rm -p 1025:1025 -p 8025:8025 axllent/mailpit
import { createMailer } from "sently/mailer";
import { MailpitTransport } from "sently/transports/mailpit";

const mailpit = new MailpitTransport();
const mailer = await createMailer({ transport: mailpit });
await mailer.send({
  from: "dev@example.com",
  to: "you@example.com",
  subject: "Hello",
  text: "Captured by Mailpit",
});

Open http://localhost:8025, or list messages from code:

const inbox = await mailpit.messages();
console.log(inbox.messages[0]?.Subject);

Configuration

OptionTypeDefaultMeaning
hoststring"localhost"SMTP hostname
portnumber1025SMTP port
securebooleanfalseImplicit TLS on connect
requireTLSbooleanfalseRefuse AUTH without TLS
authSMTPAuthOptional SMTP credentials
tlsTLSOptionsTLS options when TLS is enabled
connectionTimeoutnumberSocket connect timeout (ms)
adapterSocketAdapterauto-detectedRuntime TCP adapter
apiUrlstring"http://localhost:8025"Web UI / REST API base
apiAuth{ user, pass }Basic auth for the UI/API

provider is "mailpit". verify() checks SMTP; close() closes the socket adapter. webUrl is the UI base (same as apiUrl).

Features

Pick a branch. Channel send goes through mailer; everything else is called on mailpit. Message ids may be a Mailpit id or "latest".

Transactional send via the channel mailer (SMTP into Mailpit).

await mailer.send({
  from: "dev@example.com",
  to: "you@example.com",
  subject: "Welcome",
  html: "<h1>Hello</h1><a href=\"https://example.com\">Go</a>",
  text: "Hello",
});

REST failures throw MailpitError (provider: "mailpit"). Empty getMessage("") / search("") throws with status 400.

Troubleshooting

Learn more

  • Inbucket — another local SMTP catcher with a mailbox REST API
  • SMTP — generic SMTP when you are not on Mailpit
  • Preview — write .eml files to disk instead
  • Email channelcreateMailer contract
  • Mailpit API — full REST surface on the catcher

Next

On this page