I have this nodejs app am running and am trying to send an email to newly register users like a verification link. On my local server it works well but when I deployed to heroku it always fails.
my nodejs code
var transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
auth: {
user: 'gmail.com',
pass: 'password'
}
});
var mailOptions = {
from: 'gmail@gmail.com',
to: email,
subject: 'Verification code',
html: `<h1 style="color:blue,font-weight:bold,text-transform-uppercase"></h1></p>
<p style="color:black,font-weight:bold,text-align:center, font-size:20px">${pin}</p>
<span>this verification process helps comfirm that your the real owner of this account, so we can
help protect you from scams</span>
<p>click the link <a href="localhost:3000/${v_address}.verification">${v_address}</a> to go to the verification page</p>`
};
transporter.sendMail(mailOptions, async function(error, info){
if (error) {
res.json({error:'failed please check details or network connection'});
}else {
const newCrete = await Create.save()
if(newCrete){
const newVerify = new Verifyuser({
email:email,
pin:pin,
address:v_address
})
const Verified = await newVerify.save()
res.json({success:'success'})
}
}
});