
Nearly every modern web app needs to send transactional emails in response to user activity: account creation, password resets, order confirmations, or verification codes.
If you're building with Node.js, there are three common ways to send them:
Simple Mail Transfer Protocol (SMTP) is the standard protocol mail servers use to pass email to each other, and the one your app uses to hand a message to a server for delivery.
When you send from a client like Gmail, the client hands the message to Gmail's SMTP server, which finds the recipient's mail server and relays the message there.
🛠️ If you choose to go the SMTP route, use a sandbox service like Mailtrap for safe testing, and make sure your production server is configured with secure defaults.
Email APIs let you send messages from your application through a hosted provider, without running your own mail server. They handle message assembly, delivery, and reputation management for you.
Popular email API services include:
Before choosing a provider, compare key features, delivery performance, uptime SLAs, and support for your use case.
A notification service like Courier sits on top of your email API or SMTP server and adds what surrounds the send: templates, routing, user preferences, and logs, across every channel.
You bring your own provider for each channel. For email, that could be your own SMTP server or a hosted email API like SendGrid, Postmark, or Amazon SES. Courier can fail over to another provider if one becomes unavailable.
Adding a channel or switching providers doesn't change your app's code: it keeps making the same send call, whether the message goes out by email, SMS, push, or a chat app like Slack or WhatsApp.
Teammates who don't write code can edit content, styling, or branding in Courier, and you can preview notifications with test data in a separate Test environment before going live.
You still deliver through an email API or SMTP server underneath, so their outages still matter. Courier reduces that risk with:
Nodemailer is a Node.js module for sending email. You can use it to create HTML or plain-text emails, add attachments, and send through different transport methods, including built-in SMTP support. Nodemailer 10 and later require Node.js 20 or newer.
Start by creating a Node.js project:
mkdir email-nodeapp && cd email-nodeapp
npm init -yThe -y flag accepts npm's defaults. Next, install Nodemailer:
npm install nodemailerThe examples use ES modules with top-level await, so save each file with an .mjs extension.
Nodemailer’s createTransport function sets how mail goes out. For SMTP, it takes a host, a port, and credentials.
To get a host URL, you need an SMTP server. For development, you can use Mailtrap, or a similar service, as a fake SMTP server. A fake SMTP server lets you avoid cluttering your real account with multiple tests while still seeing how your test emails behave: do all the buttons work the way they’re supposed to, is the formatting still correct after sending, and so on.
Create a Mailtrap account if you don’t already have one. In the Integrations dropdown on the dashboard, select Nodemailer and copy the credentials displayed.

Create an email.mjs file and add the following:
import nodemailer from "nodemailer";
const transporter = nodemailer.createTransport({
host: "smtp.mailtrap.io",
port: 2525,
auth: {
user: "<user>",
pass: "<pass>",
},
});Substitute the host, user, and password with the Mailtrap credentials you copied from the dashboard above. Now you can send an email with the transporter’s sendMail method.
Append the following to email.mjs:
const message = {
from: "from-example@email.com",
to: "to-example@email.com",
subject: "Subject",
text: "Hello SMTP Email",
};
try {
const info = await transporter.sendMail(message);
console.log(info);
} catch (err) {
console.log(err);
}For an HTML email, add an html property. Keep text too: Nodemailer sends both, and clients that don't render HTML show the plain-text version.
const message = {
from: "from@email.com",
to: "to@email.com",
subject: "Subject",
text: "Hello SMTP Email",
html: "<h1>Hello SMTP Email</h1>",
};Run it:
node email.mjsGo to your Mailtrap dashboard to see your email was received.

This tutorial uses SendGrid. SendGrid no longer has a free plan, but its 60-day trial lets you send 100 emails a day.
Sign up for SendGrid, then create an API key. Go to Settings > API Keys in the SendGrid console, click “Create API Key,” and give the key a name. For permissions, choose “Custom Access” and grant Mail Send only, so a leaked key can't change anything else on your account. Click “Create & View,” then copy the key.
Next, install the SendGrid JavaScript client with npm:
npm install @sendgrid/mailSet your API key as an environment variable:
export SENDGRID_API_KEY="<SENDGRID_API_KEY>"Create a file in your project directory named sendgrid.mjs and add the following:
import sendgrid from "@sendgrid/mail";
sendgrid.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: "test@example.com", // Change to your recipient
from: "test@example.com", // Change to your verified sender
subject: "Sending with SendGrid Is Fun",
text: "and easy to do anywhere, even with Node.js",
html: "<strong>and easy to do anywhere, even with Node.js</strong>",
};
try {
const [response] = await sendgrid.send(msg);
console.log("Email sent, status:", response.statusCode);
} catch (error) {
console.error(error);
}The from address must be a verified sender identity, which you create under Settings > Sender Authentication. Set to to an inbox you can check.
Run it:
node sendgrid.mjsThen open “Activity” in the SendGrid console to see the message and whether it was delivered.
Courier is a multichannel notifications platform: one API for email, SMS, push, in-app, and chat. You can bring your own email service provider, including SMTP, or any of the popular email APIs like SendGrid, Amazon SES, and Postmark.
To start using Courier, create an account. The Developer plan includes 10,000 messages a month free. A new workspace's Test environment comes with a test email provider already set up, so you can send before you connect your own. It delivers only to the address you signed up with, so use that address as the recipient in this tutorial.
Make sure the environment dropdown at the top of the console says Test. Then follow these steps:
Hi {{data.name}}, welcome aboard. Courier auto-saves as you edit. Other blocks (Button, Image, Heading) work the same way, and variables like {{profile.email}} and {{data.x}} work anywhere in the content.export COURIER_API_KEY="<YOUR_TEST_API_KEY>"Next, install the Courier Node.js SDK, @trycourier/courier:
npm install @trycourier/courierCreate a file in your project directory named courier.mjs and add the following:
import Courier from "@trycourier/courier";
const courier = new Courier({ apiKey: process.env.COURIER_API_KEY });
const { requestId } = await courier.send.message({
message: {
to: { email: "<EMAIL_ADDRESS>" },
template: "<TEMPLATE_ID>",
data: { name: "Ada" },
},
});
console.log("Email sent, request ID:", requestId);The send.message call takes a message object with three fields:
to: who receives the email. For a user you've stored in Courier, pass { user_id: "<USER_ID>" } instead.template: the Template ID you copied from Design Studio. You can also create an alias for it.data: the values merged into your template. Here, name fills {{data.name}}.Run it:
node courier.mjsFor a single recipient, the requestId it prints is also the message ID. To check the email's status, open Logs in the Courier console. Logs lists every message in the current environment, newest first, with its status. Open a message to see its timeline, including any error.
When you're ready to go live, create a Production key in Settings → API Keys, copy the template over with Migrate assets, and connect your own email provider in Production. Integrations don't carry over from Test, and a Test key's sends only show up in Test logs. See environments and API keys for details.
If email is all you need, Nodemailer or an email API like SendGrid gets you sending quickly. If you expect to add SMS, push, Slack, or an in-app inbox later, or want teammates who don't write code to edit the content, Courier keeps it in one place: bring your own email provider (SMTP or API), design notifications visually or in code, and add channels through the same API.
Sign up for Courier and start building multichannel notifications.

How to protect your email domain and sending reputation
AI agents have made spoofing cheap, and a DMARC record at p=none won't stop it. Here's how to enforce DMARC without bouncing your own mail, keep password resets apart from newsletters, protect your sending reputation, read Google Postmaster Tools, and audit your domain with six AI prompts.

Courier's Response to the eMudhra and PHP Security Issues
Courier's assessment of the eMudhra certificate authority compromise and the October 21 PHP security release: what happened, the steps we're taking, and what you may want to check in your own environment.

Control how fast Courier sends to your providers
You shouldn't have to think about how fast you send to Courier. Set a send rate limit on any provider, and Courier sends your notifications to it at the rate you choose. Anything over the limit is queued, not dropped.