这是 imports/api/friends/methods.js
:
import {Meteor} from "meteor/meteor";
import {Accounts} from "meteor/accounts-base";
if (Meteor.isServer) {
Accounts.emailTemplates.siteName = "....";
Accounts.emailTemplates.from = "example01 <example01@gmail.com>";
Accounts.emailTemplates.verifyEmail.from = function () {
return "example01 <example01@gmail.com>";
};
Accounts.emailTemplates.verifyEmail.text = function(user, url) {
return '<h1>Thank you for your registration.</h1><br/><a href="' + url + '">Verify eMail</a>';
};
}
这就是结果:
正如您所看到的,这种格式已被Gmail所淹没。我们可以查看HTML标记<h1>
和<br>
。
为什么它们不显示为HTML?
答案 0 :(得分:3)
您使用了错误的功能。如果您使用Accounts.emailTemplates.verifyEmail.text
,正文将以文本形式返回,而不是HTML。因此,您应该使用Accounts.emailTemplates.verifyEmail.html
。
例如:
Accounts.emailTemplates.verifyEmail.html = function(user, url) {
/* Return your HTML code here: */
return '<h1>Thank you for your registration.</h1><br/><a href="' + url + '">Verify eMail</a>';
};
详细了解 Accounts.emailTemplates
。