I am trying to send mail using nodemailer node module and configured like this.
... config.js ...
smtp: {
host: "smtp.gmail.com",
port: 465,
secure: true,
auth: {
user: "***@gmail.com",
pass: "****"
}
}
... mail.js ...
const config = require("../config");
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport(config.smtp);
const sendEmail = async (data, res) => {
// if(!data.to || !data.subject)
// return false;
data = { ...data, from: config.smtp.auth.user };
console.log(data)
transporter.sendMail(data, (error, info) => {
console.log(error);
res.send(error);
});
res.send(true)
}
module.exports = sendEmail;
... controller ...
router.get('/testEmail', async (req, res) => {
let emailData = {
to: "***@gmail.com",
subject: "Welcome to Musical World",
text: "test test"
};
let result = sendEmail(emailData, res);
console.log(result)
// res.send(result);
})
When I try to send email, it returns
{"code":"EAUTH","response":"535-5.7.8 Username and Password not accepted. Learn more at\n535 5.7.8 https://support.google.com/mail/?p=BadCredentials p25-20020a056638217900b0033c14d2386bsm898629jak.75 - gsmtp","responseCode":535,"command":"AUTH PLAIN"}
So I did googling and found that's why I didn't turn on less secure app in my google account. But when I went there, google said
I tried to turn on less secure apps , but Gless secure apps feature isn't available.
What do I have to do , then?

