试图让Email.send()在Meteor上工作

时间:2015-10-18 03:34:45

标签: javascript html meteor smtp gmail

我尝试阅读文档并在线阅读教程,但似乎没有任何工作。我正在尝试将包含从联系表单收集的数据的电子邮件发送到我自己的Gmail帐户。我正在使用Meteor。到目前为止,这是我的代码:(注意:已经做过'流星添加电子邮件'&尝试使用' MAIL_URL =" smtp://#:#@ smtp.gmail.com: 465" meteor'在终端有和没有流星启动功能 - 真的不确定我在这里做错了什么)

if(Meteor.isClient) {
  Template.home.events({
    'form submit' : function(e,t){
      var to  = t.find("#contact-email").value,
          subject = t.find("#contact-name").value,
          text = t.find("#contact-message").value;
      Meteor.apply('sendEmail', [to, subject, text]);
    }
  });
}

if(Meteor.isServer){

  Meteor.startup(function () {
  smtp = {
    username: '#',   
    password: '#',   
    server:   'smtp.gmail.com',  
    port: 465
  }

  process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.server) + ':' + smtp.port;
});


  Meteor.methods({
    sendEmail: function(to, subject, text){

      Email.send({
        from: "#",
        to: to,
        subject: subject,
        text: text
      });
    }
  });
}

我有这个代码在源/ views / home文件夹中使用HTML表单(HTML在Home.html中,javascript在Home.js中)。如果您需要有关此问题的任何其他代码/信息,请与我们联系。非常感谢!! :d

0 个答案:

没有答案
相关问题