> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Attachments

> Stick files onto your emails — PDFs, images, invoices, whatever you need.

# Attachments 📎

Want to send a PDF receipt? An image? A spreadsheet? No problem. You can attach basically any file to any email you send through Mailofly.

***

## How it works

Attachments go inside the `attachments` array in your request. Each file needs a name and its content (encoded in base64 — more on that in a sec).

Here's what each attachment object looks like:

| Field | What it is |
| :- | :- |
| `filename` | The name that shows up in the email (e.g. `invoice.pdf`) |
| `content` | The file, converted to a base64 string |
| `content_type` | Optional. The MIME type like `application/pdf` or `image/png` |
| `disposition` | Optional. `"attachment"` (default) or `"inline"` (embed in email body) |
| `content_id` | Optional. Used when you want to embed images inline with a `cid:` reference |

***

## Example: Attaching a PDF invoice

```typescript theme={null}
import { Mailofly } from "@mailofly/node";
import * as fs from "fs";

const mailofly = new Mailofly("mfly_live_your_api_key");

// Read the file and convert it to base64
const pdfBuffer = fs.readFileSync("./invoice-101.pdf");
const base64Pdf = pdfBuffer.toString("base64");

await mailofly.emails.send({
  from: "Billing <billing@yourcompany.com>",
  to: ["customer@example.com"],
  subject: "Here's your receipt 🧾",
  html: "<p>Hi! Your receipt is attached below. Thanks for your purchase!</p>",
  attachments: [
    {
      filename: "invoice-101.pdf",
      content: base64Pdf,
      content_type: "application/pdf",
    },
  ],
});
```

***

## Example: Inline images (embed inside email)

Sometimes you want an image to appear *inside* the email, not as a separate download. Use `disposition: "inline"` and give it a `content_id`, then reference it in your HTML with `cid:`:

```typescript theme={null}
await mailofly.emails.send({
  from: "Acme <marketing@acme.com>",
  to: ["user@example.com"],
  subject: "You earned a badge! 🏅",
  html: `<p>Congrats! Here's your badge:</p><img src="cid:badge_image" alt="Your Badge" />`,
  attachments: [
    {
      filename: "badge.png",
      content: fs.readFileSync("./badge.png").toString("base64"),
      content_type: "image/png",
      disposition: "inline",
      content_id: "badge_image",
    },
  ],
});
```

***

## Limits to keep in mind

* 📦 **Max email size:** 25 MB total — that includes HTML, headers, and all attachments combined.
* 🚫 **Blocked file types:** Executables like `.exe`, `.bat`, `.cmd`, `.scr`, `.vbs`, `.js` are rejected automatically. This protects your recipients and keeps spam filters happy.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.