Question

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.
Was it helpful?

Solution 2

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) {   ... }

OTHER TIPS

I was recently playing around with this as well, and the error I received from Google was simply stating that I needed to create an application specific password. Try following the instructions here.

As for your second question, I do not know of any reasons as to why nodemailer can't be used in production.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top