DocsComing soon

Attachments and inline images

Attach files as base64 and show images inline with contentId.

Attachments

Each entry of attachments has a filename, the file as base64 in content, and optionally a contentType such as application/pdf. Attachments count toward the 15 MB limit of the email as sent; base64 makes a file about a third larger, so about 10 MB of attachments fit, on the API and over SMTP alike.

{
  "attachments": [
    { "filename": "invoice-1042.pdf", "content": "JVBERi0xLjcK...", "contentType": "application/pdf" }
  ]
}

A missing filename or content that is not base64 answers 422 invalid_attachment. A contentType that is not of the form type/subtype, or none at all, becomes application/octet-stream.

After the send, GET /v1/emails/{id}/content lists the attachments as sent and GET /v1/emails/{id}/content/attachments/{index} streams the bytes of one, index being its position in that list; see Reading emails.

Inline images

Give an attachment a contentId and reference it from the HTML as cid:<contentId>. The image then shows inside the email instead of as a file.

{
  "html": "<p><img src=\"cid:logo\" alt=\"Acme\" width=\"120\"></p>",
  "attachments": [
    { "filename": "logo.png", "content": "iVBORw0KGgo...", "contentType": "image/png", "contentId": "logo" }
  ]
}

A contentId uses letters, digits and !#$%&'*+/=?^_`{|}~.@-, at most 128 characters, and each one appears once per email.