Skip to content

Attachments

MX18 allows you to include file attachments in your email messages, whether you send through the API or SMTP. Attachments can enhance transactional emails such as invoices, statements, reports, and more.


What is an attachment?

An attachment is any file (like a PDF or image) sent along with your email that the recipient can download or view.

Attachments are encoded and included as part of your email payload when using the API, or embedded into the email body when using SMTP.


Supported formats

MX18 supports all major email-compatible attachment formats, including:

  • .pdf
  • .jpg, .jpeg
  • .png
  • .txt
  • .csv
  • .doc, .docx
  • .xls, .xlsx
  • .zip

📌 Executable files (.exe, .js, etc.) are blocked by most mailbox providers and are discouraged.


API payload with attachments

To send attachments via API, use the attachments field inside your message object. The file content must be base64-encoded.

Example

"message": {
  "subject": "Invoice Attached",
  "content": [
    {
      "type": "text/plain",
      "value": "Hello, please find your invoice attached."
    }
  ],
  "attachments": [
    {
      "type": "application/pdf",
      "file_name": "invoice.pdf",
      "disposition": "attachment",
      "data": "<base64_encoded_string>"
    }
  ]
}

Attachment fields

Field Description
type MIME type of the file (e.g., application/pdf)
file_name File name as it should appear for the recipient
disposition attachment or inline
data Base64-encoded content of the file

Attachments in SMTP

MX18 supports sending attachments via SMTP using standard MIME encoding (multipart/mixed).

  • Embed the file within your email content following the RFC-822 standard

  • Make sure to encode your attachments using base64

  • Use proper headers like Content-Disposition, Content-Type, and Content-Transfer-Encoding


Size limits & billing consideration

  • The maximum payload size is 20MB, including both body content and attachments.

  • It is recommended to keep each email payload under 19MB to avoid delivery issues.

Billing calculation includes:

  • Base message size: 200KB

  • Each additional 200KB (or part thereof) is charged as 1 additional email unit

Example: A 600KB email counts as 3 units for billing purposes.


Need help?

  • Make sure your attachments are properly base64 encoded

  • Keep total size under 20MB for maximum deliverability

  • Reach out to support@mx18.com for assistance