电子邮件发送问题是Meteor中未定义的电子邮件 [英] Email.send issue is email is not defined in Meteor

查看:158
本文介绍了电子邮件发送问题是Meteor中未定义的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Meteor发送电子邮件。我做了关于发送邮件的代码。我已经添加了一封电子邮件。但是我有一个错误。我不知道发生了什么。查看错误&



错误:

  =>流星服务器运行于:http:// localhost:3000 / 
I20140118-10:54:35.900(5.5)?调用方法'sendEmail'时异常引用
ce错误:未定义电子邮件
I20140118-10:54:35.989(5.5)?在Meteor.methods.sendEmail(app / loginapp.js:13
7:39)
I20140118-10:54:35.989(5.5)? at maybeAuditArgumentChecks(packages / livedata /
livedata_server.js:1349)
I20140118-10:54:35.990(5.5)? at packages / livedata / livedata_server.js:569
I20140118-10:54:35.990(5.5)?在_.extend.withValue(packages / meteor / dynamics
_nodejs.js:35)
I20140118-10:54:35.990(5.5)?在packages / livedata / livedata_server.js:568
I20140118-10:54:35.992(5.5)?在_.extend.withValue(packages / meteor / dynamics
_nodejs.js:35)
I20140118-10:54:35.992(5.5)?在_.extend.protocol_handlers.method(packages /
livedata / livedata_server.js:567)
I20140118-10:54:35.992(5.5)?在packages / livedata / livedata_server.js:472

JS代码:

  if(Meteor.isClient)
{
Template.hello.greeting = function()
{
return 欢迎来电邮。
};

Template.hello.events
({
'click input':function()
{
//模板数据(如果有的话)可用在'this'
if(typeof console!=='undefined')
console.log(您按下按钮);
//在您的客户端代码中:异步发送电子邮件
Meteor.call('sendEmail',
'*****@gmail.com',
'****@gmail.com',
'你好Meteor!',
'这是Email.send的测试。');
}
});
}

if(Meteor.isServer)
{
Meteor.startup(function()
{
//运行代码服务器启动时
process.env.MAIL_URL ='smtp://****@gmail.com:**password**@smtp.sendgrid.net:587';

});
Meteor.methods
({
sendEmail:function(to,from,subject,text)
{
console.log(*** sendEmail *** );

//让来自同一个客户端的其他方法调用开始运行,
//而不用等待电子邮件发送完成
this.unblock();

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


解决方案

我想你需要安装电子邮件包

 流星添加电子邮件


I need to send email by using Meteor. I did the code to regarding send mail. I have added a package email. But I got an error. I have no idea what happening. Check out the error & code below.

Error :

=> Meteor server running on: http://localhost:3000/
I20140118-10:54:35.900(5.5)? Exception while invoking method 'sendEmail' Referen
ceError: email is not defined
I20140118-10:54:35.989(5.5)?     at Meteor.methods.sendEmail (app/loginapp.js:13
7:39)
I20140118-10:54:35.989(5.5)?     at maybeAuditArgumentChecks (packages/livedata/
livedata_server.js:1349)
I20140118-10:54:35.990(5.5)?     at packages/livedata/livedata_server.js:569
I20140118-10:54:35.990(5.5)?     at _.extend.withValue (packages/meteor/dynamics
_nodejs.js:35)
I20140118-10:54:35.990(5.5)?     at packages/livedata/livedata_server.js:568
I20140118-10:54:35.992(5.5)?     at _.extend.withValue (packages/meteor/dynamics
_nodejs.js:35)
I20140118-10:54:35.992(5.5)?     at _.extend.protocol_handlers.method (packages/
livedata/livedata_server.js:567)
I20140118-10:54:35.992(5.5)?     at packages/livedata/livedata_server.js:472

JS Code :

if (Meteor.isClient)
 {
  Template.hello.greeting = function () 
  {
    return "Welcome to email.";
  };

  Template.hello.events
  ({
    'click input' : function ()
    {
      // template data, if any, is available in 'this'
      if (typeof console !== 'undefined')
        console.log("You pressed the button");
        // In your client code: asynchronously send an email
            Meteor.call('sendEmail',
            '*****@gmail.com',
            '****@gmail.com',
            'Hello from Meteor!',
            'This is a test of Email.send.');
    }
  });
}

if (Meteor.isServer) 
{
  Meteor.startup(function () 
  {
    // code to run on server at startup
    process.env.MAIL_URL = 'smtp://****@gmail.com:**password**@smtp.sendgrid.net:587';

  });
  Meteor.methods
  ({
  sendEmail: function (to, from, subject, text) 
  {
     console.log("*** sendEmail ***");

    // 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
    });
  }
});
}

解决方案

i think you need to have email package installed

meteor add email

这篇关于电子邮件发送问题是Meteor中未定义的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆