如何在流星中发送 html 外部模板?

How to send html external template in meteor?

我正在使用 Accounts.emailTemplates.enrollAccount.html。 我可以使用此代码成功发送电子邮件:

   Accounts.emailTemplates.enrollAccount.html = function(user, url) {
      return '<h1>Thank you </h1><br/><a href="' + url + '">Verify eMail</a>';
  };

但我想做的是,我有一个名为 email.html 的外部文件,我想将该文件作为电子邮件发送。 我的代码

  Accounts.emailTemplates.enrollAccount.html = function(user, url) {
      // i want to send email.html file from here or if you have other way
  };

谢谢。

你可以像这样使用 meteor 包 meteorhacks:ssr :

Accounts.emailTemplates.enrollAccount.html = function(user, url) {
  SSR.compileTemplate('htmlEmailVerify', Assets.getText('email.html'));
  return SSR.render('htmlEmailVerify', {user: user, url: url});
};

并且您可以使用空格键标签获取电子邮件 html 代码中的数据: {{user}} & {{url}}