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/mailpitimport { 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
| Option | Type | Default | Meaning |
|---|---|---|---|
host | string | "localhost" | SMTP hostname |
port | number | 1025 | SMTP port |
secure | boolean | false | Implicit TLS on connect |
requireTLS | boolean | false | Refuse AUTH without TLS |
auth | SMTPAuth | — | Optional SMTP credentials |
tls | TLSOptions | — | TLS options when TLS is enabled |
connectionTimeout | number | — | Socket connect timeout (ms) |
adapter | SocketAdapter | auto-detected | Runtime TCP adapter |
apiUrl | string | "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
Mailpit is not running, or the SMTP port is remapped. Start the container above, or set host / port to match your install.
SMTP and the UI/API can bind to different hosts. Set apiUrl (and apiAuth if the UI requires Basic auth).
The message has no HTML part, or Mailpit could not parse it. Send html (not only text) and retry with "latest" or the message id.
Yes, if you only need SMTP. MailpitTransport adds local defaults and REST helpers for tests and inspection.
Learn more
- Inbucket — another local SMTP catcher with a mailbox REST API
- SMTP — generic SMTP when you are not on Mailpit
- Preview — write
.emlfiles to disk instead - Email channel —
createMailercontract - Mailpit API — full REST surface on the catcher