Chat bot builder? Go to buzzmark.chat

Integration guide · SMTP

Send Next.js email with Buzzmark.

Next.js has no mailer of its own, so most apps use Nodemailer on the server. This guide sets up one shared Nodemailer transport for Buzzmark, sends from a Route Handler, and reuses the same settings for Auth.js magic links.

Environment .env.local
# .env.local
BUZZMARK_TOKEN=bzm_srv_...
EMAIL_FROM="Acme <hello@acme.com>"
Transport Nodemailer
// lib/mailer.ts
import nodemailer from "nodemailer";

export const mailer = nodemailer.createTransport({
  host: "smtp.buzzmarkapp.com",
  port: 587,
  secure: false,     // starts plain, then upgrades with STARTTLS
  requireTLS: true,  // refuse to send if STARTTLS fails
  auth: {
    user: process.env.BUZZMARK_TOKEN,
    pass: process.env.BUZZMARK_TOKEN,
  },
});
Route Handler TypeScript
// app/api/welcome/route.ts
import { mailer } from "@/lib/mailer";

export const runtime = "nodejs";

export async function POST(request: Request) {
  const { email } = await request.json();

  await mailer.sendMail({
    from: process.env.EMAIL_FROM,
    to: email,
    subject: "Welcome to Acme",
    text: "Thanks for signing up.",
    html: "<p>Thanks for signing up.</p>",
  });

  return Response.json({ ok: true });
}
Auth.js TypeScript
// auth.ts
import NextAuth from "next-auth";
import Nodemailer from "next-auth/providers/nodemailer";

export const { handlers, auth, signIn, signOut } = NextAuth({
  adapter: /* your database adapter */,
  providers: [
    Nodemailer({
      server: {
        host: "smtp.buzzmarkapp.com",
        port: 587,
        auth: {
          user: process.env.BUZZMARK_TOKEN,
          pass: process.env.BUZZMARK_TOKEN,
        },
      },
      from: process.env.EMAIL_FROM,
    }),
  ],
});

Troubleshooting

Why do I get a "wrong version number" or SSL error when connecting?

secure is set to true. That means implicit TLS, which is for port 465. Buzzmark uses port 587 with STARTTLS, so set secure to false. The connection is still encrypted, and requireTLS: true makes Nodemailer refuse to send if it is not.

Why does the build or request fail with "Module not found: net" or a similar error?

The code is running on the Edge runtime, or was imported into a Client Component. Nodemailer needs Node.js network APIs. Send from a Route Handler or Server Action on the Node.js runtime, and never from middleware or browser code.

What does "550 5.7.1" mean?

Buzzmark refused the message and the text after the code gives the reason. Most often the from address is on a domain that is not verified in Buzzmark.

Why does authentication fail with "535" in production but not locally?

The environment variable is missing or different on your host. Check BUZZMARK_TOKEN is set for the production environment, has no surrounding spaces or quotes, and redeploy so the new value is picked up.

Setting up something else? See all integration guides.

Rather not do DNS by hand?

Buzzmark is EU-hosted transactional email that generates your SPF, DKIM, DMARC and Return-Path records, checks them for you and warns you if they ever drift.

Free up to 300 emails a month · No credit card