Reputation: 265
I have created a main
template in Mailgun, with a {{body}}
variable within the HTML code.
Sending emails using this template works fine when passing a simple string to the body
variable, but I would like to be able to pass some HTML. Something like that:
return mailgun.messages().send({
from: fromEmail,
to: toEmail,
subject: subject,
template: "main",
"v:body": "<p>This is a <strong>parsed</strong> HTML paragraph.</p>",
}, (error, body) => {
console.log(body);
});
The email gets sent but the body
HTML is not rendered and appears as full text in the email (as in showing the tags).
Is there a way to inject HTML so that it is actually rendered?
Upvotes: 9
Views: 4956
Reputation: 63442
Since Mailgun uses Handlebars templates by default, you could use the "triple-stash" syntax {{{body}}}
instead of {{body}}
to prevent Handlebars from escaping the HTML.
Upvotes: 34