1

I use mailgun with nodejs and want to use one of their custom templates.

// using template
var resetlink = 'https://myurl.com/reset/dkadlkw334sada';
var dataMail = {
  from: 'Me <me@me.com>',
  to: 'mail@gmail.com',
  subject: 'password reset',
    template: "pwrecovery",
  "v:link":resetlink
};

// execute send
mg.messages().send(dataMail, function(error, body) {
  if (error) {
 
  }
  console.log(body);
});

This works fine and I can see the mail delivered with this variable in the log console of mailgun.

However, I need this link inside the email template. I tried

<td class="em_white" height="42" align="center" valign="middle" style="font-family: Arial, sans-serif; font-size: 16px; color:#ffffff; font-weight:bold; height:42px;"><a href=%recipient.link% target="_blank" style="text-decoration:none; color:#ffffff; line-height:42px; display:block;">RESET YOUR PASSWORD</a></td>

and as well:

<p> the link: {{recipient-variables.link}} </p>

But none of that worked. How can I access and show this variable, the resetlink, inside the html template?

codebird456
  • 505
  • 8
  • 19

2 Answers2

0

Add {{{ link }}} to the mailgun template and make sure the variable that is assigned link is like this

<a href='http//google.com' /a>

A tag with the actual https link in it and passed as template variable.

  const templateVars = {
         link: `<a href="${link}">Link</a>`}
godhar
  • 1,128
  • 1
  • 14
  • 34
0

Since Mailgun uses Handlebars templates by default, you could use the "triple-stash" syntax {{{link}}} instead of {{link}} to prevent Handlebars from escaping the HTML.