Sending

Attachments

Attach files to an email as base64 content or a hosted URL, with per-file and total size limits.

Add files to an email with the attachments array. Each attachment is either inlined as base64 content or referenced by a hosted `path` URL that MailBlastr fetches when the email is sent.

Attachment fields

filenamestringrequired

The name the file is presented with in the recipient's mail client (e.g. invoice.pdf).

contentstringoptional

The file contents, base64-encoded. Provide either content or path.

pathstringoptional

A hosted URL MailBlastr fetches at send time. Provide either path or content. The fetch is SSRF-guarded.

content_typestringoptional

Optional MIME type for the attachment (e.g. application/pdf). Inferred from the filename when omitted.

content_idstringoptional

Embeds the attachment as an inline image; reference it in your HTML via <img src="cid:...">. Only meaningful when the attachment is an image.

Each attachment must provide exactly one of content or path. An attachment with neither is rejected.

Size limits

LimitValue
Per attachmentup to 25 MB
Total per emailup to 40 MB

These limits cover the decoded bytes. Note that base64 encoding inflates the payload by roughly 33%, so a 25 MB file is about 34 MB of content in the request body. For large files, prefer path so MailBlastr streams the bytes server-side.

Attachments are not supported on the batch endpoint (POST /emails/batch). To send an email with an attachment, use a single POST /emails request.

Send with an attachment (hosted URL)

The simplest form points path at a hosted file — MailBlastr fetches it at send time, so you never base64-encode anything yourself.

import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.emails.send({
  "from": "Acme <hello@yourdomain.com>",
  "to": ["delivered@example.com"],
  "subject": "Your invoice",
  "html": "<p>Invoice attached.</p>",
  "attachments": [
    {
      "filename": "invoice.pdf",
      "path": "https://yourdomain.com/invoices/invoice.pdf"
    }
  ]
});
console.log({ data, error });
A path URL is fetched through an SSRF-guarded client and must return the file with a 2xx status. If the fetch fails or the file exceeds the size limit, the send is rejected with a validation_error.

Send with base64 content

Or inline the bytes directly as base64 content — useful for files you generate in memory and never host.

import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.emails.send({
  "from": "Acme <hello@yourdomain.com>",
  "to": ["delivered@example.com"],
  "subject": "Your invoice",
  "html": "<p>Invoice attached.</p>",
  "attachments": [
    {
      "filename": "invoice.pdf",
      "content": "JVBERi0xLjQKJ...base64...",
      "content_type": "application/pdf"
    }
  ]
});
console.log({ data, error });