Other transports
In addition to the default SMTP transport you can use other kind of transports as well with Nodemailer. Some transports are built-in, some need an external plugin. See Available Transports below for known transports.
The following example uses SES transport (Amazon SES).
let nodemailer = require("nodemailer");
let aws = require("@aws-sdk/client-ses");
process.env.AWS_ACCESS_KEY_ID = "....";
process.env.AWS_SECRET_ACCESS_KEY = "....";
const ses = new aws.SES({
apiVersion: "2010-12-01",
region: "us-east-1",
});
let transporter = nodemailer.createTransport({
SES: { ses, aws },
});
Available transports
Built-in transports
- sendmail – for piping messages to the sendmail command
- SES – is a Nodemailer wrapper around aws-sdk to send mail using AWS SES
- stream – is just for returning messages, most probably for testing
External transports
- Mailtrap – integration with the official API for Mailtrap
- Mailgun – send emails with Mailgun API
- your own (see transport api documentation here)
General options for transports
Even though every transport has its own set of configuration options there are a few that can be used for every transport type
- attachDataUrls – if true, then converts data: images in the HTML content in every message to embedded attachments
- disableFileAccess – if true, then does not allow to use files as content. Use it when you want to use JSON data from untrusted source as the email. If an attachment or message node tries to fetch something from a file the sending returns an error
- disableUrlAccess – if true, then does not allow to use Urls as content
- normalizeHeaderKey(key) – a method that is applied to every header key before inserting to generated rfc822 message. Example