Tips for Using Images in Mandrill Emails

Mandrill doesn't store images for you, but there are a few ways to include them in your emails. Below are some tips to help you get started.

  • Upload images to a publicly-accessible server or a reputable image hosting service. Then, link to the image URL in your message HTML or template:

    <img src="" alt="My image" />

  • You can also use merge tags to insert image names dynamically:

    <img src="*|IMAGENAME|*" alt="My image" />

  • In general, hosting images on your own site is preferable to using general sharing services. File and photo hosting sites could have any number of users' content on them and are more likely to be flagged by spam filters, be on blacklists, or cause failed content reviews for your Mandrill account.

  • Include images as inline attachments with your API calls using the images parameter. You'll need to provide the image name (Content-ID), the content (as a base64 encoded string), and the image MIME type. Reference the image name in the 'src' in your HTML content:

    <img src="cid:image_name">

  • For most SMTP libraries, including inline images is handled automatically. For example, if you insert an image inline, an img tag is added which then references the Content-ID of the image that's attached. How to add inline images will depend on the SMTP library being used.

  • Including inline images causes emails to be much larger since attachments are base64-encoded. This also means more data is being transferred to Mandrill, and more data is also being sent to receiving servers. If you're using the same images often or sending in bulk, hosting those images and referencing them in your HTML will be more efficient.

  • Images cannot be uploaded to templates or stored in Mandrill.