Can I use merge tags in my subject line or other headers?

In addition to using merge tags to personalize your message content, you can also use merge tags to customize some email headers. Currently, merge tags are supported in the from name, subject line, and body of an email only. Merge tags can't be included in custom X- headers or the List-Unsubscribe header.


Include merge tags in your API request:

    "subject": "Your order: *|ORDERID|* has been received",

Then provide global or per-recipient merge vars:

. . . 
    "merge_vars": [
                    "rcpt": "",
                    "vars": [
                            "name": "FNAME",
                            "content": "Jane"
                            "name": "ORDERID",
                            "content": "123456"
. . .

SMTP Integration

Add merge tags in your message headers, then use the custom SMTP header, X-MC-MergeVars, to provide global or per-recipient values for those merge tags.

Template Defaults

You can also add merge tags in the Template Defaults part of your Mandrill templates. You'll still need to provide values for the merge tags in your API request or SMTP message.

  1. From the Outbound menu, select Templates.
  2. Hover over your template name and click edit code.
  3. Under Template Defaults, add your merge tag(s) in the field after From Name or Subject.

It's not possible to use a merge tag as the default From Address for your template.

If you give a different subject or from name in your API request or SMTP message, that will override your default template settings.



If you have a merge tag with a long value or have added a handful of merge tags for your message headers, you may hit header length limits with some email servers or clients. This could result in your emails appearing incorrectly for some recipients.

It's best to use merge tags for small snippets of information that you need to inject at the time of send. We strongly recommend sending a handful of live test emails to different email clients when using merge tags in message headers.