【发布时间】:2015-06-30 22:58:33
【问题描述】:
大家好,我有一个方法如下:
Meteor.methods({
sendEmail: function (to, from, name, text) {
if (Meteor.isServer) {
return Meteor.Mandrill.send({
to: to,
from: from,
name: name,
text: text
});
}
}
});
这个方法在我的contact.js中调用(html视图是contact.html):
if (Meteor.isClient) {
// This code only runs on the client
Template.Contact.events({
"click .btn": function(event) {
var from = document.getElementById('from').value;
var name = document.getElementById('name').value;
var text = document.getElementById('message').value;
Meteor.call('sendEmail', 'lolotutu@gmail.com', from, name, text);
}
});
Template.Contact.helpers({
test: "Working"
});
一切正常,但是我无法控制用于发送邮件的模板。我在这里使用 Mandrill,我想知道如何告诉我的 sendEmail 方法来提供要发送给人们的自定义模板。也许与Session.set 和Session.get 相关,但我无法实现它。谢谢。
【问题讨论】:
-
Saimeunt 举了一个很好的例子on this SO 看看
-
非常感谢!我现在明白了!
标签: templates meteor customization mailer