[英]Why is the customized Meteor accounts verification email not display as HTML?
Here's my code in imports/api/friends/methods.js
: 这是我在
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>';
};
}
And this is the result: 结果如下:
As you can see, the format is ingnored by Gmail. 如您所见,Gmail忽略了该格式。 We can se the HTML tags
<h1>
and <br>
. 我们可以识别HTML标签
<h1>
和<br>
。
Why are they not display as HTML? 为什么它们不显示为HTML?
You used the wrong function. 您使用了错误的功能。 If you use
Accounts.emailTemplates.verifyEmail.text
, the body will be returned as text and not as HTML. 如果使用
Accounts.emailTemplates.verifyEmail.text
,则正文将作为文本而不是HTML返回。 So instead, you should use Accounts.emailTemplates.verifyEmail.html
. 因此,您应该使用
Accounts.emailTemplates.verifyEmail.html
。
For example: 例如:
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>';
};
Read more about Accounts.emailTemplates
. 了解有关
Accounts.emailTemplates
更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.