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

# Attachments

> How to send files, PDFs, and invoices as attachments.

# Attachments

You can attach files (PDFs, invoices, images, spreadsheets) to any email sent with Mailofly.

***

## File Attachment Structure

Attachments are passed as an array of objects inside the `attachments` property.

```typescript theme={null}
interface Attachment {
  filename: string;
  content: string; // Base64-encoded string
  content_type?: string; // Optional MIME type
  disposition?: "attachment" | "inline"; // Default: 'attachment'
  content_id?: string; // Used for inline CID images
}
```

***

## Example: Attaching a PDF Invoice

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

const mailofly = new Mailofly("mfly_live_your_api_key");

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: "Your Monthly Receipt",
  html: "<p>Please find your receipt attached.</p>",
  attachments: [
    {
      filename: "invoice-101.pdf",
      content: base64Pdf,
      content_type: "application/pdf",
    },
  ],
});
```

***

## Inline Images (Content-ID / CID)

To display an image directly inside the email body without hosting it on an external web server, use `disposition: "inline"` and reference the `content_id` in your HTML:

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

***

## Size Limits & Restrictions

* **Total email size**: 25 MB max per message (including HTML, headers, and base64-encoded attachments).
* **Blocked file types**: Executable files (`.exe`, `.bat`, `.cmd`, `.scr`, `.vbs`, `.js`) are rejected to comply with international email security standards.


## Related topics

- [Attachments](/receiving/attachments.md)
- [Retrieve Attachment](/api/emails/retrieve-attachment.md)
- [List Attachments](/api/receiving/list-attachments.md)
