我已经创建了帮助器和事件以忘记密码,我也编写了联系电子邮件代码,代码工作成功,我可以发送电子邮件,但我想使用电子邮件模板。我做了一个验证电子邮件,使用了一个电子邮件模板,使用了一个名为“meteor add meteorhacks:ssr”的软件包,如前所述。
这是我编写的代码,plz帮助我
Template.recoverPassword.events({
'submit #recovery-form':function(e,t){
e.preventDefault();
var email= t.find('#recovery-email').value;
Accounts.forgotPassword({email: email},function(error){
if(error){
alert("unable to send reset link");
}
else{
alert("password reset link sent");
}
});
我有书面发送电子邮件的方法,如下面服务器端 methods.js
Meteor.methods({
'sendEmail' :function(from,phone,fname,subj,body){
this.unblock();
Email.send({
to:'sample@sample.com',
from:from,
subject:subj,
text:phone,
text:fname,
text:body,
html: SSR.render('contactbody', sendEmail)
})
},
请向我建议如何为忘记密码和联系电子邮件添加电子邮件模板。我试过用ssr包在私人文件夹下创建了一个电子邮件正文,并尝试在服务器端插入,但它不能正常工作,所以寻求帮助!请建议我如何接近。
答案 0 :(得分:0)
用于发送重置密码电子邮件
Accounts.emailTemplates.resetPassword.html = function (user, url) {
SSR.compileTemplate( 'registartionEmail', Assets.getText( 'email_templates/registration_confirm.html' ) );
var emailData = {
x: y;
};
return SSR.render( 'registartionEmail', emailData );
};
发送联系邮件
Clint Side:您可以使用任何编辑器来编写来自用户的邮件。您还可以使用{{username}},{{date}}等一些标记来向用户表单管理员发送邮件。
在提交事件中,您可以调用服务器方法。
Meteor.call('sendEmail',
'admin@example.com',
Meteor.user().emails[0].address,
'Hello from Meteor!',
'This is a test of Email.send.');
服务器端:
如果您在邮件正文html / text中使用spacbar,则可以使用SSR。
Meteor.methods({
sendEmail: function (to, from, subject, text) {
check([to, from, subject, text], [String]);
// Let other method calls from the same client start running,
// without waiting for the email sending to complete.
this.unblock();
Email.send({
to: to,
from: from,
subject: subject,
text: SSR.render("text", {username: "Pankaj"})
});
}
});