Using the send-template method and the Lutung Mandrill Java API implementation, when a template variable contains line breaks of the form \n, they are totally ignored or stripped on generated emails. The Strings containing \n characters are kept untouched untill the GET send-template method is executed. So I guess there is some String analysis and conversion on Mandrill servers which removes special characters.
How can I make work again line breaks on Mandrill emails?
In my case I am using Handlebars for mandrill templates and I have solved this by sending HTML to the template <br/> instead of \n by replacing \n in my string with <br/> something like: .Description.Replace("\n", "<br/>");
And then on the mandrill template I put the variable inside {{{ variable }}} instead of {{ variable }}
http://blog.mandrill.com/handlebars-for-templates-and-dynamic-content.html
HTML escaping
Handlebars HTML-escapes values returned by an
{{expression}}. If you don't want Handlebars to escape a value, use the "triple-stash", "{{{.In your template:
<div> {{{html_tag_content}}} </div>In your API request:
"global_merge_vars": [ {
"name": "html_tag_content",
"content": "This example<br>is all about<br>the magical world of handlebars" } ]
The result:
This example
is all about
the magical world of handlebars
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