After we switched from Mandrill to SparkPost we encountered issues when sending emails using transmission
. In Mandrill merge_vars
were not HTML encoded and we sometimes put HTML in them, however in SparkPost substitution_data
does appear to be HTML encoded and it's messing some of our emails. Is there a global setting that allows to turn this off or at least disable it for a transmission
?
Edit: I forgot to mention that we use csharp-sparkpost library, which means it might be a problem directly related to the library rather than SparkPost API and I need to investigate it further.
Edit2: I tested sending an email directly using JSON and the result was the same, so I can conclude that the HTML encoding is done by SparkPost and not by the c# library.
You can render HTML in substitution variables without escaping by using 3 braces around your variables. e.g. With this in your transmission:
{
"substitution_data": {
"firstName": "<em>Jimbo</em>"
},
"content": {
"html": "<p>Hi {{{firstName}}}</p>"
}
}
...you get this in your HTML message body:
<p>Hi <em>Jimbo</em></p>
There are more details in the SparkPost reference docs: https://developers.sparkpost.com/api/#/introduction/substitutions-reference/escaping-html-values