Meteor: send mail | AuthError: invalid login - 535-5.7.8

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

I am 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: PASSWORD@smtp.gmail.com :465/"; console.log(process.env.MAIL_URL); Email.send({ from: " from@gmail.com ", to: " my-email@gmail.com ", subject: "Meteor Can Send Emails via Gmail", text: "test" }); 

also tried:

 // configure email later for validation and sending messages smtp = { username: ' myusername@gmail.com ', 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 cannot find any other information about this issue or how to track it. Who can give me the key?

+5
source share
4 answers

Thanks for the suggestions guys! I fixed it by actually enabling 2-step verification, generating the application password and using it as a login. Strange decision, but it worked!

+4
source
+2
source

If you use OAuth2 and you encounter the problem above, setting 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 do not know how to generate the identifier, secret and token, follow the steps here https://medium.com/@pandeysoni/nodemailer-service-in-node-js-using-smtp-and-xoauth2-7c638a39a37e

+1
source

Try port 25. smtp = {username: ' myusername@gmail.com ', password: 'my-pw', server: 'smtp.gmail.com', port: 25};

0
source

All Articles