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}}
Choose Template > New Variable from the editor toolbar (or choose an existing variable to add it to the page) Enter a name for the variable. Press Enter (by default this will create a single-line text input field)
Use the drag and drop template editor to make the desired template, then copy the code and paste it into the Mandrill template editor. Or connect your Mandrill and Mailchimp accounts and let Mandrill copy your templates over for you.
Template variables help you use data from one part of a template in another part of the template. Use template variables to perform tasks such as respond to user input or finely tune your application's forms. A template variable can refer to the following: a DOM element within a template.
The simplest way to create templates to send through Mandrill, is to use the Mailchimp drag and drop templates, then when your template is created, click "Save and Exit". Go to the templates list, and then in the drop down to the right of the templates menu, select "Send to Mandrill".
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With