看起来Meteor中的电子邮件包现在允许添加类似于MailComposer的附件。在我的服务器上,我有:
Meteor.startup( function() {
process.env.MAIL_URL = "smtp://<my maligun info here>";
});
Meteor.methods({
sendEmail: function (to, from, subject, text, attachment) {
// 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: text,
attachment: attachment
});
}
});
在应用内部,我会有一个帮手,如:
Template.donateEmail.events({
'click #send-donate-email': function() {
var attachment = {
fileName: "Demographics3.numbers",
filePath: "/Users/Opal/Desktop/Demographics3.numbers"
};
var emailCompose = document.getElementById('compose-donate-email').value;
var emailSubject = document.getElementById('subject-donate-email').value;
Meteor.call('sendEmail',
"some@email.com", //Session.get('keyDonateEmailSendList'),
'some2@email.com',
emailSubject,
emailCompose,
attachment)
}
});
我可以收到要发送的电子邮件,但发送但没有附件。文档令人困惑。任何人都有这方面的更多信息?我在某处遗漏了一些东西。
答案 0 :(得分:1)
问题解决了。我的代码中有两个错误。在Email.send方法中,需要阅读
"attachments: <some name>" not "attachment: <some name>".
第二个问题是确保指定正确的绝对路径,在我的情况下,在Mac上将是:
"Volumes/Macintosh\ HD/Users/Opal/Desktop/<filename>"
我发现Apple .numbers文件无法打开,但会附加。其他文件应该没问题。