Attaching invoices and tickets to a transactional e-mail: base64, size limit and refused files

E-mail·· 68 views· 3 min read

The short answer: attachments go in the attachments field of the request itself, in base64, each with the file name and content. The total is up to 5 MB per e-mail and executable files are refused. For big files, send a link instead of an attachment.

How an attachment is sent

Field of each attachment What it takes
filename The name the customer sees, such as invoice-FT2026-214.pdf
content The file content in base64
content_type The type, such as application/pdf

"attachments": [{"filename": "invoice.pdf",
"content": "JVBERi0xLjQK...",
"content_type": "application/pdf"}]

In PHP, for example, the content comes from base64_encode(file_get_contents($path)). Remember that base64 makes files bigger: a PDF weighs more inside the request than on disk.

When an attachment is refused

Reason What it means What to do
invalid_attachment The name is missing or the content is not valid base64 Check the filename and the encoding
attachment_blocked This file type cannot be attached (executables) Send another format, such as PDF
attachments_too_large The attachments are over the size limit Compress them or send a link
too_many_attachments Too many attachments in one e-mail Put them in one file or split the send

These reasons come in details.reason, in a 422 answer. The others are in Email Center API errors.

Attachment or link

Use an attachment Use a link
A light invoice, receipt or ticket in PDF Catalogues, videos, folders of documents
A document the customer must keep Something that changes after it is sent
When the customer may not have access to your client area Files close to the limit, or for many recipients
Every recipient gets the whole attachment. A heavy file to 50 recipients is a lot of mail. And some servers refuse large messages: see attachment too large.
Say in the text what is attached, with the name and amount: "Attached is invoice FT 2026/214, for 1,250.00". An attachment with no explanation looks like phishing.

Want to send your PDF invoices through the API? See the API page.

See the API page

SEE ALSO

Sending a transactional e-mail through the API: the fields of POST /v1/email/messages

Transactional e-mail templates with variables: write once, fill in each customer's details

Email Center API errors: email_account_required, all_recipients_suppressed and other reasons

Attachment too large: why the message bounces and how to send big files

Password reset, order and invoice e-mails: what a good transactional message says, with examples

How to recognise a phishing e-mail or message, and what to do if you clicked

Was this answer helpful? Your answer helps us improve this article.