Email

SMTP

Send email through any SMTP server with Nodemailer.

smtp() from tenoncms/email/smtp sends through any SMTP server. It runs on Node, Vercel and Workers and needs the nodemailer package.

Set up SMTP

To add SMTP to an existing project:

Install Nodemailer

tenoncms does not install it for you:

npm install nodemailer

Set the transport and the sender

tenon.config.ts
import { defineCms } from "tenoncms";
import { smtp } from "tenoncms/email/smtp";

export default defineCms({
  // ...
  email: {
    adapter: smtp({
      host: process.env.SMTP_HOST,
      port: 465,
      secure: true,
      auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASSWORD },
    }),
    from: "My Site <hello@example.com>",
  },
});

from applies to every message. smtp() connects only when it sends.

Check that mail arrives

Invite a user under Manage → Users. The invite goes out by email.

Ports and TLS

  • Port 465 with secure: true uses TLS from the start.
  • Port 587 with secure: false uses STARTTLS. The adapter requires TLS by default.
  • On Cloudflare Workers, smtp() works on port 465 and on port 587. Port 25 is blocked. Leave pooling off.

Nodemailer options

smtp() passes its options to Nodemailer's createTransport() as they are. Set pooling, timeouts and TLS there:

tenon.config.ts
adapter: smtp({
  host: process.env.SMTP_HOST,
  port: 465,
  secure: true,
  auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASSWORD },
  pool: true,
  maxConnections: 3,
  connectionTimeout: 10_000,
  tls: { minVersion: "TLSv1.2" },
}),

Your options override the default requireTLS: true.