Simple setup & reliable delivery

Send email in Express.js

Add email sending to your Express.js app in minutes with Sidemail's clean API. From transactional emails to scheduled delivery, Sidemail handles the hard parts so your emails land in inboxes every time.

Get startedRead API docs
Send a welcome email from an Express route
const sidemail = require("./sidemail");

router.post("/register", async (req, res, next) => {
	try {
		const { email, name } = req.body;

		await sidemail.sendEmail({
			toAddress: email,
			fromAddress: "[email protected]",
			fromName: "Your App",
			templateName: "Welcome",
			templateProps: { firstName: name },
		});

		res.status(201).json({ message: "User registered" });
	} catch (error) {
		next(error);
	}
});

Quickstart: Send email in Express.js

Start sending emails from your Express app in three steps:

1

Install the Sidemail SDK

Add Sidemail to your Express.js project with npm:

npm install sidemail
2

Configure your API key

Create a sidemail.js file that exports the configured Sidemail instance. The SDK reads SIDEMAIL_API_KEY from your environment, or you can pass it directly.

// sidemail.js
const configureSidemail = require("sidemail");

const sidemail = configureSidemail({
	apiKey: process.env.SIDEMAIL_API_KEY,
});

module.exports = sidemail;
3

Send email from an Express route

Import the configured Sidemail instance and call sidemail.sendEmail inside any Express route handler. Pass the recipient, sender, email template or content, and you're done.

// Example: send a welcome email template
const express = require("express");
const router = express.Router();
const sidemail = require("./sidemail");

router.post("/register", async (req, res, next) => {
	try {
		const { email, name } = req.body;

		// ... create user in database ...

		await sidemail.sendEmail({
			toAddress: email,
			fromAddress: "[email protected]",
			fromName: "Your App",
			templateName: "Welcome",
			templateProps: { firstName: name },
		});

		res.status(201).json({ message: "User registered" });
	} catch (error) {
		next(error);
	}
});

Key features & perks

Why Sidemail for Express.js emails

  • Quick Express.js email integration

    Start sending emails from your Express.js routes in minutes. Sidemail's JSON API and official Node.js SDK are designed for fast integration, with clear documentation and ready-to-use code examples that get you up and running in under 30 minutes.
  • Reliable email delivery

    Sidemail's infrastructure and careful sender vetting process mean your emails consistently land in inboxes, not spam folders. It's built for developers who want dependable delivery without the complexity. Fast to set up, simple to manage, and designed to just work.
  • Custom sending domain with DKIM & SPF

    Send from your own domain without the hassle of manual DNS configuration. Sidemail automatically sets up DKIM and SPF for you. These are two of the most important factors for strong inbox placement and sender reputation.
  • All-in-one email platform

    Sidemail handles everything in one place. Transactional and marketing emails, newsletters, email automation, subscriber collection, and contact management. One platform that covers every email use case.
  • Premade email templates & no-code editor

    Get started with a library of production-ready, tested email templates that look great in every inbox. Want something custom? The no-code email editor lets you modify existing templates or build responsive ones from scratch, all without writing any HTML.
  • Best-in-class developer experience

    Sidemail is built for developers who value their time. Clear documentation, copy-paste code snippets in multiple languages, and thoughtful features like markdown email support, detailed logs, an MCP server, and rich API data make integration and daily use genuinely enjoyable.

Express.js transactional email examples

Sidemail makes it easy to send any transactional email from Express.js. Here are a few common examples with code:

// Express.js: Send an account activation email
const sidemail = require("./sidemail");

router.post("/register", async (req, res, next) => {
  try {
    const { email, name } = req.body;
    const token = generateActivationToken();

    await sidemail.sendEmail({
      toAddress: email,
      fromAddress: "[email protected]",
      fromName: "Your App",
      templateName: "Account Activation",
      templateProps: {
        firstName: name,
        activateUrl: `https://yourapp.com/activate?token=${token}`,
      },
    });

    res.status(201).json({ message: "User registered" });
  } catch (error) {
    next(error);
  }
});

Account activation email template

Send an activation email with a one-time link right from your Express registration route.

  • Sidemail provides a ready-made account activation template with a clear call-to-action button. Pass the activation URL via templateProps.
  • Best practice is to include a clear button or link and set the activation token to expire for security.
See account activation email template
// Express.js: Send a password reset email with Markdown
const fs = require("fs");
const path = require("path");
const sidemail = require("./sidemail");

router.post("/forgot-password", async (req, res, next) => {
  try {
    const markdown = fs.readFileSync(
      path.join(__dirname, "../templates/emails/password-reset.md"),
      "utf8"
    );

    // Subject and sender are defined in the markdown frontmatter
    await sidemail.sendEmail({
      toAddress: req.body.email,
      markdown: markdown,
      templateProps: {
        firstName: "Alex",
        resetLink: "https://yourapp.com/reset?token=abc123xyz",
        expiresIn: "30 minutes",
      },
    });

    res.json({ message: "Reset email sent" });
  } catch (error) {
    next(error);
  }
});

Password reset email with Markdown

Sidemail lets you write email content in Markdown and automatically converts it into responsive, pixel-perfect emails that look great on every device and in every inbox. Each email is branded with your logo and styled to match your project's design.

  • Store your email content in a .md file and keep the sender and subject in frontmatter.
  • Pass dynamic values like resetLink and expiresIn via templateProps, which map to variables in your markdown.
// Express.js: Schedule a welcome email for 1 hour from now
const sidemail = require("./sidemail");

const scheduledAt = new Date(Date.now() + 60 * 60 * 1000).toISOString();

await sidemail.sendEmail({
	toAddress: "[email protected]",
	fromAddress: "[email protected]",
	fromName: "Your App",
	templateName: "Welcome",
	templateProps: { firstName: "Alex" },
	scheduledAt: scheduledAt,
});

Scheduled email delivery

Schedule an email to be delivered later, for example one hour after a user signs up.

  • Set the scheduledAt field to an ISO 8601 timestamp and Sidemail will deliver the email at exactly that time.
  • Great for onboarding sequences where you want to delay the first message until the user has had time to explore your app.
See welcome email template
// Express.js: Send an invoice email with PDF attachment
const fs = require("fs");
const sidemail = require("./sidemail");

router.post("/send-invoice", async (req, res, next) => {
  try {
    const pdfData = fs.readFileSync("./invoices/invoice-1042.pdf");
    const attachment = sidemail.fileToAttachment("invoice-1042.pdf", pdfData);

    await sidemail.sendEmail({
      toAddress: req.body.email,
      fromAddress: "[email protected]",
      fromName: "Your App",
      templateName: "Invoice",
      templateProps: {
        customerName: req.body.name,
        invoiceNumber: "#1042",
        amount: "$99.00",
        dueDate: "April 15, 2026",
      },
      attachments: [attachment],
    });

    res.json({ message: "Invoice sent" });
  } catch (error) {
    next(error);
  }
});

Invoice email with attachment

Send an invoice email with a PDF attachment using a Sidemail premade template and dynamic data from your Express route.

  • Use the SDK's sidemail.fileToAttachment() helper to attach files, then include them in the attachments array.
  • Supported file types include PDF, PNG, JPG, and CSV. Keep total attachment size under about 2.5 MB for best results.
See invoice email template

Deliverability best practices

SPF, DKIM, and DMARC for transactional email

SPF and DKIM are email authentication protocols that prove your emails are legitimately sent from your domain. DMARC builds on top of both, telling mail servers how to handle messages that fail those checks. Together, these three protocols are critical for inbox placement and sender reputation.

Sidemail takes care of SPF, DKIM, and DMARC configuration for you automatically. Your Express.js app sends fully authenticated, best-practice-compliant emails from day one.

Sidemail dashboard – Reliable email delivery
Graphics
Sidemail dashboard – No-code email editor
Graphics

The simplest way to build emails

No-code email editor & premade email templates

Sidemail's visual email editor is the fastest way to create responsive templates that render correctly in every email client and on every device. No HTML knowledge needed. Add your logo and brand colors, and start sending right away.

Want to move even faster? Choose from a library of production-ready templates for common use cases like password resets, welcome emails, and receipts. Whether you build from scratch or customize an existing template, your emails will look polished everywhere.

Learn more

Developer-friendly formatting

Markdown support for Express.js emails

Building and maintaining HTML emails by hand is painful, especially when all you want is clean, readable content.

With Sidemail, you write your email body in Markdown and it gets automatically converted into a responsive, well-styled HTML email. Smart formatting like headings, lists, links, and code blocks works out of the box, with no broken layouts or cross-client rendering issues.

Perfect for transactional emails sent from your Express.js routes. Clean content, fast authoring, zero HTML to debug.

Learn more
Markdown email code example and rendered preview

Get started today

Ready to send emails from your Express.js app? With Sidemail's API and premade templates, you can integrate in minutes and deliver emails reliably.

Start free trial

FAQs

How do I send email in Express.js?

The simplest way to send email in Express.js is with an email API like Sidemail. Install the Sidemail SDK (npm install sidemail), initialize it with your API key, and call sidemail.sendEmail() inside any Express route handler. You can send templated or custom emails with just a few lines of code. Sidemail takes care of authentication, formatting, and deliverability for you.

What is the best way to send transactional emails from Express.js?

Using a dedicated email API like Sidemail is the most reliable approach. Unlike self‑managed SMTP or basic email libraries, Sidemail gives you automatic DKIM and SPF authentication, managed deliverability, premade email templates, and a simple SDK that fits naturally into Express route handlers and middleware. This means higher inbox placement, less maintenance, and faster development.

How do I use email templates in Express.js?

Instead of building email HTML in your Express routes, use Sidemail's template system. In the Sidemail dashboard, pick a premade template or create your own with the drag‑and‑drop editor. Then in your Express route, reference the template by templateName and pass personalization data via templateProps. For example, a "Welcome" template with a {firstName} variable can be sent by calling sidemail.sendEmail() with the matching prop. Sidemail merges the data and delivers a well‑formatted email.

Can I send attachments with Express.js emails?

Yes. Sidemail supports email attachments. Read the file in Node (as a Buffer) and use the SDK's sidemail.fileToAttachment(name, data) helper to create the attachment object. Then include it in the attachments array of your email payload. Keep total attachment size under about 2.5 MB and use allowed file types like PDF, PNG, JPG, or CSV.

Can I schedule an email to send later from Express.js?

Yes. Add the scheduledAt field with a future ISO 8601 timestamp (for example, 2026-04-10T09:00:00Z) to your sendEmail() call. Sidemail queues the message and delivers it at the specified time. You can view or cancel scheduled emails from the dashboard or via the API.

How do I handle email sending errors in Express.js?

Wrap your sidemail.sendEmail() call in a try/catch block and pass errors to Express's next(error) function. This lets your global error handler take care of it. Sidemail returns clear error messages and status codes, making it easy to log and debug issues.

Does Sidemail work with Express.js middleware?

Absolutely. Since Sidemail is a standard Node.js SDK, it works anywhere in your Express app. Call it from route handlers, middleware, event emitters, or background jobs. You can also use patterns like Node.js EventEmitter to decouple email sending from your route logic for cleaner code.