Skip to main content

Email Adapters

Used to send emails.

Email adapter base class

AWS SES Email Adapter​

pnpm add @adminforth/email-adapter-aws-ses

Enables email delivery via Amazon Simple Email Service (SES), suitable for high-volume, programmatic email sending.

Mailgun Email Adapter​

pnpm add @adminforth/email-adapter-mailgun

Allows sending transactional or marketing emails using Mailgun, a developer-friendly email service.

SMTP Email Adapter​

pnpm add @adminforth/email-adapter-smtp

Sends emails through any SMTP server: your own mail server, Google Workspace, Microsoft 365, or the SMTP endpoint of an email service. Built on Nodemailer.

import EmailAdapterSmtp from '@adminforth/email-adapter-smtp';

const adapter = new EmailAdapterSmtp({
host: 'smtp.example.com',
// 587 for STARTTLS, 465 for TLS from the start of the connection
port: 587,
// omit for servers that accept mail without authentication
auth: {
user: process.env.SMTP_USER as string,
pass: process.env.SMTP_PASS as string,
},
});

Pass the adapter to a plugin that sends emails, for example Email password reset.

Optional settings:

OptionDefaultDescription
securetrue for port 465, false otherwiseUse TLS from the start of the connection. When false, the connection is upgraded with STARTTLS.
requireTLStrueRefuse to send if the connection can't be encrypted.
connectionTimeout10000How long to wait for the connection to open, in milliseconds.
greetingTimeout10000How long to wait for the server's greeting once connected, in milliseconds.
socketTimeout60000How long to wait for the server to respond before sending fails, in milliseconds.

Many cloud providers block outgoing connections on port 25, so use port 587 or 465.

For local development with a mail catcher such as Mailpit, which has no TLS, turn off requireTLS:

const adapter = new EmailAdapterSmtp({
host: 'localhost',
port: 1025,
requireTLS: false,
});

Don't turn it off in production: credentials and email contents would go over the network unencrypted.