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
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 channelcreateMailer / createSMTPMailer
  • Runtimes — socket adapters

Next

On this page