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 .txt .csv .json .xml .jpg, .jpeg .png .gif .webp .doc, .docx .xls, .xlsx .ppt, .pptx .zip .7z .rar .tar .gz


Refer below the file types and their MIME formats to be used while sending attachments:

File type MIME Format
pdf application/pdf
txt text/plain
csv text/csv
json application/json
xml application/xml text/xml
jpg image/jpg
jpeg image/jpeg
png image/png
gif image/gif
webp image/webp
doc application/msword
docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
xls application/vnd.ms-excel
xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
ppt application/vnd.ms-powerpoint
pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
zip application/zip
7z application/x-7z-compressed
rar application/vnd.rar application/x-rar-compressed
tar application/x-tar
gz application/gzip application/x-gzip

📌 Please note, only above mime formats are supported.

📌 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",
      "name": "myfile.pdf",
      "data": "<base64_encoded_string>"
    }
  ]
}

Attachment fields

Field Description
type MIME type of the file (e.g., application/pdf)
name Name of the file sending through attactments
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