我需要使用流星发送电子邮件.我做了关于发送邮件的代码.我添加了包裹电子邮件.但是我有一个错误.我不知道发生了什么.检查错误&下面的代码.
错误:
=> 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代码:
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
});
}
});
}
解决方法:
我认为你需要有email package installed
meteor add email
标签:meteor,email,javascript 来源: https://codeday.me/bug/20191122/2058085.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。