I'm using a digitalocean ubuntu server. I deployed a node app to send emails.
var transporter = nodemailer.createTransport({
service: 'gmail',
host:'smtp.gmail.com',
auth: {
user: '[email protected]',
pass:'EmailPassword'
}
});
var mailOptions = {
from: 'Express Delivery',
to: req.body.name,
subject: 'password reset',
text: ``,
html:'<h1>express delivery</h1><hr><p><h2>your verification code is : '+v_code+'</h2><h2>please enter this code to reset your account</h2></p>'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
res.status(500);
res.send({'data':'email sending fail','err':error});
} else {
console.log('Email sent: ' + info.response);
res.status(200);
res.send({'data':'sent verification code'});
});
}
});
but i have an error.
{ "data": "email sending fail", "err": { "code": "EAUTH", "response": "534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbs\n534-5.7.14 EwlrhFraZdJas3vVEewnbhmhqPf5l2FEb63fMy3QW_TRXzv5f-xmbOtJ5eGJUf38kJvY3\n534-5.7.14 vHxXfNwHWjF0G4hNb9-L9Xp-jIWSmfAWRVz7utNbdFQ5mucKosCrvWz2v0571O2q>\n534-5.7.14 Please log in via your web browser and then try again.\n534-5.7.14 Learn more at\n534 5.7.14 https://support.google.com/mail/answer/78754 22sm9807004qkg.15 - gsmtp", "responseCode": 534, "command": "AUTH PLAIN" } }
This is the error. I want to know how to send email using smtp. and what is the error.
follow these things