I use Meteor.js and I want to customize the reset password email body. I need to insert html code in the message body. I can do this with the following code:
Accounts.emailTemplates.resetPassword.html = function (user, url) {
return //html-code here
};
But how do I insert text from a separate file?
You can use the meteorhacks:ssr package to perform Server Side Rendering of templates (i.e. a separate file) into your email body.
Write your html content inside the /private
directory, for example:
<!-- file: private/forgotPassword.html -->
Dear <b>{{username}}</b>,<br/>
Please click on this link to reset your password<br/>
{{url}}
Then load it like this:
Accounts.emailTemplates.resetPassword.html = function (user, url) {
SSR.compileTemplate('forgotPassword', Assets.getText('forgotPassword.html'));
return SSR.render("forgotPassword", { username: user.username, url: url });
};