Cannot use gmail SMTP

I am trying to use gmail smtp using node_mailer. I get the following error in 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 do not get stack errors, but email is not delivered.

@ work4liberty and @David Ellis. Thanks for your data, but it seems that the problem was not in my server code, I sent the wrong value to emailId from my client side javascript. Nodemailerhelped me debug the problem with the correct text by mistake.

+3
source share
2 answers

A couple of things:

  1. Your code, as written, will throw an interpreter error and will not start. (There are no quotes around the email address, for example.)
  2. . Nodemailer , , SMTP gmail.

: Amazon SES Nodemailer ( 0.1.x 0.3.x , git blame).

: . , , , : this.now.successfullySent(result);

, this - , . this , self. (, .)

+6

xxx , , , , (, ) ip - msg, gmail ,

var email = require('mailer');
email.send({
    host : "smtp.gmail.com",
    port : "465",
    ssl : true,
    domain : "domain.com",
    to : "work4liberty@gmail.com",
    from : "work4liberty@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 $
    username : 'work4liberty@gmail.com',
    password : 'xxx'
    },
    function(err, result){
      if(err){ self.now.error(err); console.log(err); return;}
      else console.log('looks good')
});
+2

All Articles