I get this while trying to send an email with sendgrid. I’m using the https://github.com/DavidBrear/meteor-sendgrid and meteor “email” package.
Exact error message:
20160128-17:05:21.028(1)? Exception while invoking method ‘sendEmail’ { stack: ‘TypeError: Object [object Object] has no method ‘send’\n at [object Object].Meteor.methods.sendEmail (server/method/email.js:46:11)\n at [object Object].methodMap.(anonymous function) (packages/meteorhacks_kadira/lib/hijack/wrap_session.js:164:1)\n at maybeAuditArgumentChecks (livedata_server.js:1698:12)\n at livedata_server.js:708:19\n at [object Object]..extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)\n at livedata_server.js:706:40\n at [object Object]..extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)\n at livedata_server.js:704:46\n at tryCallTwo (C:\Users\Anders\AppData\Local\.meteor\packages\promise\0.5.1\npm\node_modules\meteor-promise\node_modules\promise\lib\core.js:45:5)\n at doResolve (C:\Users\Anders\AppData\Local\.meteor\packages\promise\0.5.1\npm\node_modules\meteor-promise\node_modules\promise\lib\core.js:171:13)’,
I20160128-17:05:21.029(1)? source: ‘method’ }
This code has worked a couple of days ago so I think it’s related to some other package conflicting with this or eaven worse.
The Method:
Meteor.methods({
sendEmail: function (email) {
if(!email.type) {
email.type = ‘text’;
}
check([email.type, email.from, email.to, email.subject, email.body], [String]);
this.unblock();
if(email.type && email.from && email.to && email.subject && email.body) { Meteor.Sendgrid.send({ to: email.to, from: email.from, subject: email.subject, text: email.body }); } else { throw new Meteor.Error("Error", "E-mail was not sent"); }
}
});
I have a server startup script that sets a correct smtp-url in “MAIL_URL” Env-variable.
config.js
Meteor.startup(function(){
Meteor.Sendgrid.config({
username: ‘’,
password: ‘’
});
});
sendgrid.js
Meteor.Sendgrid = {
config: function(options){
username = options[‘username’];
password = options[‘password’];
host = ‘@smtp.sendgrid.net’;
port = ‘465’;
process.env.MAIL_URL = ‘smtp://’ + username + ‘:’ + password + host + ‘:’ + port + ‘/’;
},
send: function(options){
Email.send(options);
}
}
I have tested and replaced “Meteor.Sendgrid.send” with “Email.send” and also removed the “email” package and added it again but still the same result.
How do I do more advanced debugging to find the root cause of this in my Meteor app?
Thankfull for all your help!