流星电子邮件附件

时间:2015-09-15 17:15:26

标签: meteor

我已将流星更新为1.2,我现在正尝试使用电子邮件附件功能,但不知道如何使用。

Meteor的指南说参考this,但它不是很有用..

if(true == true){
      var dataAttachments = attachment;
      var dataText = 
      "Client Name: " + name + 
      "\rEmail: " + email + 
      "\rPhone: " + phone + 
      "\rCompany: " + company +
      "\rDeliverables: " + deliverables +
      "\rCopywriting: " + copywriting +
      "\rPrint Services: " + print +
      "\rIllustration: " + illustration +
      "\rphotography: " + photography + 
      "\rTimelines: " + timelines +
      "\rBudget: " + budget +
      "\rDescription: " + description;

      Meteor.call('sendEmail', dataText, dataAttachment);
      //throwAlert is my helper method which creates popup with message
      alert('Email sent');
    }else{
      alert('An error occurred. Sorry');
      return false;
    }
  }
});

Meteor.methods({
  sendEmail: function (text) {
    check([text], [String]);

    this.unblock();

    Email.send({
      to: 'jaeeun@antarcti.cc',
      from: 'contact@myClientProject.com',
      subject: 'New message from contact form',
      text: text
    });

    Email.send().addAttachment(attachment);
  }
});

1 个答案:

答案 0 :(得分:1)

我建议安装此软件包:https://atmospherejs.com/ashutosh/email-att 然后做:

var attachments = [];
attachments.push({filename: "xxx", filePath: "xxx"});
var email = {
    from:    "test@gmail.com",
    to:      "test2@gmail.com",
    subject: "Test!",
    text:    "Text!"
    attachmentOptions: attachments
};
Meteor.call('send_one_email_with_attachments', email, function(){});


Meteor.methods({
    send_one_email_with_attachments: function(email){
        this.unblock();
        EmailAtt.send(email);
    };
});

在我打了Meteor的内置电子邮件一段时间之后,这让我的生活变得轻松了许多。它甚至可以并排使用,因此您仍然可以使用旧的非附件电子邮件功能!