问题
Here's my code in 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. We can se the HTML tags <h1>
and <br>
.
Why are they not display as HTML?
回答1:
You used the wrong function. If you use Accounts.emailTemplates.verifyEmail.text
, the body will be returned as text and not as HTML. So instead, you should use 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.
来源:https://stackoverflow.com/questions/41493811/why-is-the-customized-meteor-accounts-verification-email-not-display-as-html