I am using nodemailer to send emails. Every post ive seen so far sugegest to generate a password in google since 2022. I followed these steps:
- from manage your account
- select security
- from Signing in to Google ==> make your account 2- step verification
- from Signing in to Google ==> select app passwords
- make a password for nodemailer and use it instead of your password
but still I always get the error:
Invalid login: 535-5.7.8 Username and Password not accepted
my code where I use the generated password:
let transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: {
user: 'myRegularEmail@gmail.com',
pass: 'qwlbhgd...', // generated password
},
});
let info = {
from: 'myRegularEmail@gmail.com',
to: "receipient@yahoo.com",
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello worldddd?</b>", // html body
};
transporter.sendMail(info, function (err, info) {
if (err) {
return ('Error while sending email' + err)
} else {
res.status(200).send("it worked")
}
});
I feel like Im doing everything how its suggested. What am I doing wrong?
I used a gmail generated password, I use the 2 steps verification and sue the code thats suppose to work.