Hey @hyla526, before moving forward, I want to confirm that this code is in a Netlify function? If it’s not, then it’s not getting deployed since, with Netlify and the Jamstack in general, there’s no server at runtime. If it is, please go ahead and send your Netlify URL and an x-nf-request-id so we can dig in further!
In the meantime, I wanted to share another post on this topic that may be helpful:
A small tip for gmail. You can make an app specific password for nodeMailer.
If you have enabled 2-factor authentication on your Google account you can’t use your regular password to access Gmail programmatically. You need to generate an app-specific password and use that in place of your actual password.
Log in to your Google account
Go to My Account > Sign-in & Security > App Passwords
(Sign in again to confirm it’s you)
Scroll down to Select App (in the Password & sign-in method box) and choose Other (custom name)
Give this app password a name, e.g. “nodemailer”
Copy the long generated password and paste it into your Node.js script instead of your actual Gmail password. (You don’t need the spaces.)