Mailmus
Mail

Send your first email

Quickstart — send a transactional email with the server SDK.

Install the SDK

npm install mailmus

Send an email

import { SDK } from "mailmus";

const mailmus = new SDK({
  bearer: process.env.MAILMUS_SECRET_KEY, // secret key — never on the client
});

await mailmus.emails.transactionalEmailsSend({
  projectId: "proj_xxx",
  body: {
    to: ["recipient@example.com"],
    from: "hello@yourdomain.com",
    subject: "Welcome!",
    html: "<h1>Welcome, {{first_name}}!</h1>",
    variables: { first_name: "Alice" },
  },
});

from must belong to a verified domain (DKIM/SPF/DMARC) on your project.

Attachments

await mailmus.emails.transactionalEmailsSend({
  projectId: "proj_xxx",
  body: {
    to: ["recipient@example.com"],
    from: "hello@yourdomain.com",
    subject: "Your invoice",
    html: "<p>Invoice attached.</p>",
    attachments: [
      {
        filename: "invoice.pdf",
        content: pdfBuffer.toString("base64"),
        contentType: "application/pdf",
      },
    ],
  },
});

Up to 10 attachments, 8 MB in total (decoded size).

Next

On this page