Skip to main content
Pass an attachments array to sendMessage(...).
const inbox = await mail.inbox({ new: true });

await inbox.sendMessage({
  to: ["invoices@example.com"],
  subject: "Invoice",
  text: "Attached.",
  attachments: [
    {
      fileName: "invoice.txt",
      content: Buffer.from("invoice total: $10.00"),
      type: "text/plain",
    },
  ],
});

Inline Attachment

Use contentId when the HTML body references an inline file.
await inbox.sendMessage({
  to: ["preview@example.com"],
  subject: "Inline image",
  html: '<img src="cid:logo" alt="Logo" />',
  attachments: [
    {
      fileName: "logo.png",
      contentId: "logo",
      content: logoBuffer,
      type: "image/png",
    },
  ],
});
For all attachment fields, see the Mail Reference.
Last modified on April 24, 2026