Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

meteor: send email | AuthError: Invalid login - 535-5.7.8

Tags:

email

meteor

I've installed the email package and tried to sent a test mail, but it presents me with the following error: AuthError: Invalid login - 535-5.7.8 Username and Password not accepted

I'm sure the credentials are correct and the code is the same as: https://github.com/ideaq/meteor-email

/server/init.js

process.env.MAIL_URL="smtp://USERNAME%40gmail.com:[email protected]:465/";
console.log(process.env.MAIL_URL);

Email.send({
    from: "[email protected]",
    to: "[email protected]",
    subject: "Meteor Can Send Emails via Gmail",
    text: "test"
});

also tried:

// configure email later for validation and sending messages
smtp = {
    username: '[email protected]',
    password: 'my-pw',
    server:   'smtp.gmail.com',
    port: 465
};

process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.server) + ':' + smtp.port;

I can't seem to find any other information around this problem or how to followup on it. Who can give me a clue?

like image 847
flowen Avatar asked May 22 '15 08:05

flowen


3 Answers

thx for the suggestions guys! I fixed it by actually turning ON 2-step verification, generate an app password and use THAT as login. Strange solution, but it worked!

like image 84
flowen Avatar answered Oct 13 '22 09:10

flowen


  1. Solution: It's the gmail security for less secure apps. Also a quick solution will be to turn off the access Allow less secure apps

  2. Solution: Best way will be to work with 2-Step verification 2-Step Verification

like image 21
Roman S Avatar answered Oct 13 '22 10:10

Roman S


In case you're using OAuth2 and you're facing the issue above, configuring my transporter as shown below resolved the error for me.

const transporter = nodemailer.createTransport({
  host: 'smtp.gmail.com',
  port: 465,
  secure: true,
  auth: {
    type: 'OAuth2',
    user: process.env.MAIL_USER,
    clientId: process.env.GOOGLE_CLIENT_ID,
    clientSecret: process.env.GOOGLE_CLIENT_SECRET,
    refreshToken: process.env.GOOGLE_CLIENT_REFRESH_TOKEN
  }
});

If you're not sure how to generate the id, secret and token, follow the steps here https://medium.com/@pandeysoni/nodemailer-service-in-node-js-using-smtp-and-xoauth2-7c638a39a37e

like image 40
Kehinde Adedamola Shittu Avatar answered Oct 13 '22 09:10

Kehinde Adedamola Shittu