Transports

SMTP

Connect to an SMTP relay with host, port, and auth.

Connect to an SMTP relay for production or a local catcher. Prefer createSMTPMailer when your config starts with host and port — it picks a runtime adapter for you.

The one rule

Use createSMTPMailer for host/port config; use createMailer only with an explicit SMTPTransport that already has an adapter.

Quick start

import { createSMTPMailer } from "sently/smtp";

const mailer = await createSMTPMailer({
  host: "smtp.example.com",
  port: 587,
  auth: { user: "you@example.com", pass: process.env.SMTP_PASSWORD! },
});
await mailer.send({
  from: "hello@example.com",
  to: "person@example.com",
  subject: "Hello",
  text: "Hi",
});

Configuration

OptionTypeDefault or requirement
hoststringrequired
portnumber587, or 465 when secure
securebooleanfalse
authSMTPAuthoptional
requireTLSbooleantrue when auth is set
starttls"required" | "opportunistic" | "never"opportunistic
clientNamestringOS hostname, else [127.0.0.1]
connectionTimeoutnumber30000 ms on Node and Bun; 0 disables
greetingTimeoutnumberconnectionTimeout when set, else 30000; 0 disables
socketTimeoutnumberconnectionTimeout when set, else 60000; 0 disables
sendTimeoutnumberunset; 0 disables the whole-send deadline
attachmentBasePathstringunset; path is trusted local I/O
adapterSocketAdapterauto via createSMTPMailer
poolbooleanfalse
dkimDKIMConfigoptional

For local capture with defaults and REST helpers, use Mailpit or Inbucket instead of hand-wiring SMTP ports.

Troubleshooting

Learn more

  • Mailpit — local SMTP catcher with inbox API
  • Inbucket — local SMTP catcher with mailbox REST API
  • Email channel — createMailer / createSMTPMailer
  • Runtimes — socket adapters

Next

On this page