-2
I understand that there are some posts about how to send email using Nodejs and nodemailer, but after many attempts I still receive the fault Answer: '535-5.7.8 Username and Password not accepted when trying to send email.
I checked several times login and password, configured so that Google allows less secure applications.
This glitch could be some line of code I haven’t found yet.
--> email js.
module.exports = {
host: 'smtp.gmail.com',
port: 587,
user: '[email protected]',
pass: 'minha senha',
};
const SMTP_CONFIG = require('../config/email');
const transporter = nodemailer.createTransport({
host: SMTP_CONFIG.host,
port: SMTP_CONFIG.port,
secure: false,
auth: {
user: SMTP_CONFIG.user,
pass: SMTP_CONFIG.pass
},
tls: {
rejectUnauthorized: false,
}
});
var welcome = {
from: SMTP_CONFIG.user,
to: '[email protected]',
subject: 'Teste de e-mail',
html: '<h1>Teste envio de e-mail</h1>'
};
transporter.sendMail(welcome, function (err, info) {
if (err) {
console.log(err);
}
else {
console.log('Email enviado: ' + info.response);
}
});
Thanks Eduardo.. I checked the 2-Factor Auth and it was enabled.. You can classify my question as positive.. Many should have this kind of doubt / problem.
– Roberto Vieira
Now this. Just a repair, did not select this answer as correct and I think I helped him. About your question, I found the same clear. Continuation of good work!
– Eduardo Salvadinha