Skip to main content

Adding attachments

The attachments array attaches files to your email. Each entry is an object with the MIME type of the file, the filename shown to the recipient, and content containing the file’s bytes as a base64-encoded string. See Embedding inline images below for the optional content_id field.

Limits

  • Up to 1000 attachments per email.
  • 30 MB combined limit on attachments and email content. Messages that exceed this are rejected.

Forbidden attachments

The following MIME types and file extensions are blocked because they are commonly associated with malware. Sending an attachment with a forbidden type or extension returns an error. MIME types
  • application/x-msdownload
  • application/vnd.ms-htmlhelp
  • application/java-archive
  • application/x-sh
  • application/x-shellscript
File extensions .ade, .adp, .bat, .chm, .cmd, .com, .cpl, .exe, .hta, .ins, .isp, .jar, .jse, .lib, .lnk, .mde, .msc, .msp, .mst, .pif, .scr, .sct, .sh, .shb, .sys, .vb, .vbe, .vbs, .vxd, .wsc, .wsf, .wsh

Embedding inline images

Setting content_id on an attachment embeds it inline in the message body instead of showing it as a downloadable attachment. Reference the image from HTML content with a cid: URI that matches the content_id, for example <img src="cid:logo"> for an attachment with content_id: "logo".
content_id must be unique across all attachments in the request.
Never send an attachment that you received from a user without first scanning it for viruses and malware.