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
pnpm add nodemailer
yarn add nodemailer
bun add 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: trueuses TLS from the start. - Port 587 with
secure: falseuses 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.
Related resources
- Email: send your own mail and change the built-in emails.
- Cloudflare Email Service: also accepts SMTP.