首页 > 解决方案 > 如何访问mailgun模板中的自定义变量?

问题描述

我将 mailgun 与 nodejs 一起使用,并希望使用他们的自定义模板之一。

// 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);
});

这工作正常,我可以在 mailgun 的日志控制台中看到使用此变量传递的邮件。

但是,我需要电子邮件模板中的这个链接。我试过了

<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>

还有:

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

但这些都不起作用。如何在 html 模板中访问和显示这个变量 resetlink?

标签: javascripthtmlnode.jsmailgunhtml-templates

解决方案


推荐阅读