I am trying to use gmail smtp using node_mailer. I get following error on my nodejs logs (using nodester). Here is my code:
var email = require('mailer');
email.send({
host : "smtp.gmail.com",
port : "465",
ssl : true,
domain : "domain.com",
to : "emailId@gmail.com",
from : "email@gmail.com",
subject : "You have been registered",
body: "<B>Hello! This is a test of the node_mailer.</B>",
authentication : "login", // auth login is supported; anything else is no auth
username : /* username */,
password : /* password */
},
function(err, result){
if(err){ self.now.error(err); console.log(err); return;}
else this.now.successfullySent(result);
});
I am not getting any error in the stack but email is not getting delivered.
@work4liberty and @David Ellis. Thanks for both of yours inputs but it seems that the problem was not with my server code, I was sending incorrect value in emailId from my client-side javascript. Nodemailer did help me debug the issue with correct text in error.
A couple things:
Full Disclosure: I contributed the Amazon SES functionality to Nodemailer (though a recent rewrite of the underlying architecture from 0.1.x to 0.3.x means I don’t show up on
git blame, anymore).EDIT: I took a closer look at your code. Assuming you don’t have the typos in your actual code, I suspect the following line is the culprit:
this.now.successfullySent(result);Basically, the callback function’s
thisis not what you think it is. You’ll want to cache thethisobject in its scope by assigning it to a variable likeself. (Assuming we’re not dealing with a problem in the underlying library.)