Mailmus
Mail

Envoyer son premier email

Quickstart — envoyer un email transactionnel avec le SDK serveur.

Installer le SDK

npm install mailmus

Envoyer un email

import { SDK } from "mailmus";

const mailmus = new SDK({
  bearer: process.env.MAILMUS_SECRET_KEY, // clé secrète — jamais côté client
});

await mailmus.emails.transactionalEmailsControllerSend({
  appId: "app_xxx",
  body: {
    to: ["destinataire@example.com"],
    from: "hello@votredomaine.com",
    subject: "Bienvenue !",
    html: "<h1>Bienvenue, {{first_name}} !</h1>",
    variables: { first_name: "Alice" },
  },
});

from doit appartenir à un domaine vérifié (DKIM/SPF/DMARC) sur votre App.

Pièces jointes

await mailmus.emails.transactionalEmailsControllerSend({
  appId: "app_xxx",
  body: {
    to: ["destinataire@example.com"],
    from: "hello@votredomaine.com",
    subject: "Votre facture",
    html: "<p>Facture ci-jointe.</p>",
    attachments: [
      {
        filename: "facture.pdf",
        content: pdfBuffer.toString("base64"),
        contentType: "application/pdf",
      },
    ],
  },
});

Maximum 10 pièces jointes, 8 Mo cumulés (taille décodée).

Suivant

On this page