Mail
Send your first email
Quickstart — send a transactional email with the server SDK.
Install the SDK
npm install mailmusSend 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 on your project. A domain is verified once two kinds of DNS records are visible: the ownership record (TXT _mailmus.<your domain> with the value shown in the dashboard, unique to your account) and the three DKIM records (CNAME). SPF and DMARC are recommended for deliverability. Each record, with its exact name and value, is under Domains → See the DNS.
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
- Contacts, audiences and campaigns — for marketing sends rather than transactional ones.
- Webhooks — get notified of opens, clicks and bounces.