mandrill template variables not substituting

4.4k Views Asked by At

Having issue with template variables not substituting when sending an email. I have a simple template:

<div class="entry"> Your name is {{firstName}} </div>

And my python code to send an email:

client = mandrill.Mandrill(apikey=api_key)

my_merge_vars = [{'content': 'Dexter', 'name': 'firstName'}]
message = {'from_email': '[email protected]',
       'to': [{'email': '[email protected]',
               'name': 'Deborah',
               'type': 'to'}
       ],
       'subject': 'example subject',
       'global_merge_vars': my_merge_vars

}
result = client.messages.send_template(template_name='test-template',
                          template_content=[],
                          message=message)

The email sends, however I get: Your name is {{firstName}}

1

There are 1 best solutions below

1
On BEST ANSWER

Make sure you specify that the merge type is handlebars. You can either do it in your account settings (Settings > Sending Defaults > Merge Language) or in your API call via the 'merge_language' parameter.