电子邮件中的HTML无法呈现

时间:2015-03-01 12:22:13

标签: meteor

我使用meteor-ssr包在服务器端呈现电子邮件模板并发送它们

模板:

Hello

A request to change your payment account was sent. If this was not you, your account may be compromised and you should reset your password immediately.

New account: {{pending.email}}

Click the link below to confirm the change.
<a href="{{id}}">{{id}}</a>

和服务器

sendPaymentChangeToken: function() {
      SSR.compileTemplate('paymentChangeEmail', Assets.getText('paymentChange.html'));
      var user   = Meteor.user();
      var email  = user.emails[0].address;
      var token  = user.payment.token;

      var html = SSR.render("paymentChangeEmail", token);
      Email.send({
        from: 'Tabler <no-reply@tabler.com>',
        to: email,
        subject: 'Payment Confirmation',
        text: html
      });
    }

问题是我呈现为

的链接标记
 <a href="27d8bdca14be4522abdb5fddf9f86c9f8ba29a3500660">27d8bdca14be4522abdb5fddf9f86c9f8ba29a3500660</a>

而不是实际提供链接

任何帮助都非常感谢

3 个答案:

答案 0 :(得分:1)

您要将HTML字符串分配给the text property instead of the html property

不要发送纯HTML电子邮件,这对垃圾邮件过滤器来说是一个很好的平台。发送包含等效HTML和纯文本部分的多部分电子邮件。如果您为htmltext分配值,则希望电子邮件包可以正确使用。

答案 1 :(得分:1)

您需要更改文字,例如akshat

 Email.send({
        from: 'Tabler <no-reply@tabler.com>',
        to: email,
        subject: 'Payment Confirmation',
        text: html
      });

 Email.send({
        from: 'Tabler <no-reply@tabler.com>',
        to: email,
        subject: 'Payment Confirmation',
        html : html
      });

答案 2 :(得分:0)

假设sendPaymentChangeToken中的令牌被映射到SSR模板中的{{id}},看起来您忘记包含服务器URL。

尝试:

var token = Meteor.absoluteUrl() + user.payment.token;