Skip to main content

Other transports

Nodemailer ships with a fully‑featured SMTP transport enabled by default, but you’re by no means limited to SMTP. A transport is simply the mechanism Nodemailer uses to hand off a fully‑constructed email message—whether that’s piping into sendmail, posting to an HTTPS API, or any other delivery strategy.

This page lists the transports that are bundled with Nodemailer as well as popular community transports. You can also roll your own by following the transport API documentation.


Example: Amazon SES transport

Below is a minimal example that delivers mail through Amazon SES using the built‑in SES transport. It wraps the official AWS SDK v3 client under the hood.

Install dependencies
npm install nodemailer @aws-sdk/client-sesv2
send‑with‑ses.js
const nodemailer = require("nodemailer");
const { SESv2Client, SendEmailCommand } = require("@aws-sdk/client-sesv2");

const sesClient = new SESv2Client({});

const transporter = nodemailer.createTransport({
SES: { sesClient, SendEmailCommand },
});

(async () => {
await transporter.sendMail({
from: "you@example.com",
to: "friend@example.net",
subject: "Hello from SES",
text: "This message was sent with Nodemailer & Amazon SES!",
});
})();

Available transports

Bundled (built‑in) transports

TransportPurposeReference
SMTPDefault transport that speaks the SMTP protocolDocs
sendmailPipes the generated message to a local sendmail‑compatible binaryDocs
SESSends mail via the AWS SES API using the AWS SDKDocs
streamReturns the generated rfc822 stream instead of sending (useful for testing)Docs

Community transports

These transports live in separate NPM packages maintained by the community. Install them with npm install and pass their exported function to nodemailer.createTransport().

  • Mailtrap – Deliver messages to your Mailtrap inbox for safe testing (npm)
  • Mailgun – Send via Mailgun’s HTTP API (npm)
  • Custom – Implement business‑specific logic by authoring your own transport

Heads‑up Third‑party transports are not maintained by the Nodemailer team. Check each project’s README for installation and usage instructions.


Transport‑agnostic options

While each transport defines its own configuration object, the following options are recognised by all transports:

OptionTypeDescription
attachDataUrlsBooleanConvert inline data: URIs in HTML content to embedded attachments.
disableFileAccessBooleanDisallow reading files from disk when resolving attachments or HTML images. Useful when the message source is untrusted.
disableUrlAccessBooleanDisallow HTTP/HTTPS requests when resolving attachments or HTML images.
normalizeHeaderKey(key)FunctionCallback invoked for every header key before it’s added to the generated RFC 822 message. Example