我正在尝试在服务器端发送一封html电子邮件,这就是我所关注的
meteor add blaze
。var dataContext = {
from: "wrs@mw.com",
to: event.speakers[i].email,
name: event.speakers[i].fname + " " + event.speakers[i].lname,
subject: "Invitation to Event <h3>" + event.title + " !",
message: "You must see this, it's amazing !",
url: "http://myapp.com/content/amazingstuff"
};
Meteor.call('sendInvitationEmail', dataContext);
Meteor.methods({
sendInvitationEmail: function(subject, data) {
var html = Blaze.toHTML(Blaze.With(data, function() {
return Template.invitation;
}));
Email.send({
to: data.to,
from: data.from,
subject: data.subject,
html: html
});
}
});
<template name="invitation">
Hello {{name}},
{{title}}
{{message}}
{{url}}
</template>
我收到错误:
“调用方法'sendInvitationEmail'时出错:内部服务器错误[500]”
答案 0 :(得分:0)
这是解决方案:
meteor add cmather:handlebars-server
安装此软件包后,您将可以访问服务器上的模板,例如:
html = Handlebars.templates.invitation(data)
中提供了更多文档
答案 1 :(得分:0)
服务器端呈现可以由优秀的meteorhacks:ssr包提供