I am having an issue with my portfolio site, which is currently coded using Node and Express. I am using Nodemailer with Google's SMTP for my contact form. My code is all working, my problem is actually with Google.
Sometimes the emails from my contact form will go through no problem. Other times, people will get an error because Google will send me a "Critical Security Alert" for my connected account (thus not allowing the SMTP to log in). I have already enabled less secure apps. I have searched for hours for an answer and cannot find one anywhere.
This is what my createTransport() function looks like (I have changed the email and password):
const smtpTrans = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: "[email protected]",
pass: "example"
}
})
Anyone know how I can fix this?
You need to log in your Google account and then go to https://myaccount.google.com/lesssecureapps. In that web you should set the switch to ON (should be OFF the first time you enter) so that it allows other applications to access your account
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With