Templates allow you to create your email design and store commonly used content to re-use for various transactional emails. You can store the templates in Mandrill and then send email using the template and providing dynamic, recipient-specific content.
Why use templates?
There are a few key advantages to using templates instead of providing full HTML content each time you send an email:
- Templates are more efficient because you only provide the dynamic portions of the content when an email is sent. This simplifies the payload, so troubleshooting and isolating bugs can be easier.
- Template design and copy can be edited by non-developers within your Mandrill account (or MailChimp if you use both).
Add templates to your Mandrill account
You can add templates to your Mandrill account in the following ways:
- Send a template from your MailChimp account to your connected Mandrill account.
- Custom code a template and send it to your Mandrill account via the API.
- Go to Outbound > Templates > Code Your Own in your Mandrill account to use the Mandrill code editor to custom code your template or paste your template code.
Create dynamic content (placeholders for custom content)
Mandrill has two ways to add dynamic content to your templates: using the MailChimp template language to create editable regions in your template (typically good for code injection or larger sections of content) or by using merge tags (great for smaller pieces of information like recipient name, addresses, and phone numbers). More information about adding dynamic content to your Mandrill emails: using the MailChimp template language or by using merge tags.
Inline your CSS
Mandrill does not automatically inline styles that are included in the
<head> of your templates. You can opt to have CSS inlined for HTML documents under 256KB in size. This can be done by using the
inline_css parameter (API) or
X-MC-InlineCSS (for SMTP). CSS inlining can be an intensive process and since Mandrill is designed to get your emails out as quickly as possible, the additional processing time to inline CSS can really add up. If you have a larger template or HTML document, you'll want to inline your styles manually or by using a CSS inlining tool like this one from MailChimp Labs.