user2384694 user2384694 - 5 months ago 30
Node.js Question

sending emails in node.js / nodemailer

I tried to use nodemailer to send emails using my gmail account.

However, Google rejects my login as suspicious and thinks I am a hacker.

I tried Yahoo which does send the email.

My questions are:


1) How can I configure nodemailer to send emails thru gmail
2) Standard/Reliable email library in node.js community with good support that can be used in production.


Answer

I used emailjs, and haven't had that issue. Not sure if that's because it's email.js or because it's Google Apps vs Gmail, or maybe Google is just less suspicious with this app for some reason. Maybe useful to try to triangulate:

$> npm install emailjs

   emailjs = require('emailjs');

   ...

var server = emailjs.server.connect({
        user:"myname@mygoogleapp.com",
        password:"Secret@!1",
        host:"smtp.gmail.com",
        ssl:true
      });

 server.send({
          text: message
          from:"Display name <return@mydomain.com>",
          to:email,
          subject:"Subject"
        },
        function (err, message) {   ... }