9

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': 'addr1@gmail.com',
       'to': [{'email': 'addr2@gmail.com',
               '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}}

mingxiao
  • 1,712
  • 4
  • 21
  • 33

1 Answers1

17

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.

Reza
  • 196
  • 1
  • 6