Nodemailer Struggles

Have any of you used Nodemailer before? Until this afternoon I hadn’t, but hey, it’s just another package can’t be too hard. On this site, I wanted the ability to send messages to… myself (I hope one day someone else sends me a message). Nodemailer doesn’t send the message itself but tells Gmail to send the email. The tutorials I found online were all straightforward just 35 lines of code, including nice spacing.

You’ve got mail!You’ve got mail!

In just a few minutes I was able to send an email from my site to my email, so I was really happy. It doesn’t happen very often that things just work. So I wasn’t just happy I was jumping, screaming and crying! Do you hear a ‘but…’ coming? My first thought: ‘It doesn’t happen very often that things just work’ proved to be correct when I uploaded the new code to my server. I checked the logs, I quickly saw that it couldn’t find the package ‘Nodemailer’, oooh just forgot to install it on the server. I started jumping, screaming and crying again. Too soon again… New errors! Nodemailer wasn’t allowed by Google to log in to my account. I also got a notification from Google that they blocked the login. Is Google trying to block me? I’ll use Google against itself by googling the problem, ha! Online I read more people ran into the same problem, good start. I even found a lot of answers how to cope with this problem, but the solution a lot of people suggested was using something like SendGrid… I just coded a solution with Nodemailer, so I wasn’t happy to see I used the wrong tool. But then I found a comment from P4rks. Hey guys, just found what’s going on with those errors. The problem is that when you have activated the Google Authenticator Verification you also need to set up the 2-Step-Authentication in your Gmail account. Therefore visit when you have done so, just go back to this page and click the “App Password” Settings. Select “Other (custom name)” and enter any name you like. Go ahead and copy the code and paste it to your projects settings. Done! — This resolved all issues for me. Greets P4rks! This solved my problem, this time it really did. So finally I could jump, scream and cry again. See Nodemailer in action at the bottom of this page: There’s always an answer, keep a positive mind and jump, scream and cry whenever you accomplish a task, even the small ones. Keep at it!


(06) 27002272


Amsterdam, Nederland