Nodemailer with Gmail account not working inside Cloud Functions

Viewed 348

I am trying to send a reset-password email from a noreply.myappname@gmail.com email to my users using a Gmail account and nodemailer inside a Cloud Function.

I have followed this sample code that is not working.
Here is the error i am getting :

enter image description here

So i have tried what is written : Please log in via your web browser and then try again .
I have also set the lessSecureApp to ON in my Gmail account.
I am receiving security alerts on my main Gmail account each time a Cloud Function is ran and this is still not working.

What am I doing wrong here ? (I have the exact same code as the sample, just configured the functions.config().gmailEmail and functions.config().gmailPassword with the ones of my account).

How to not have security alerts and how to make it work without the need of logging in a browser (even if it doesn't work either) which would be weird for a production app ?

1 Answers

As said in the comments, you could try activating DisableUnlockCaptcha in your G-mail account to continue in this path, but you would run into the G-mail email send quota mentioned in the repository readme. Just leaving this answer in case other users have doubts or have run into their quota limit and see an error. Since the repository recommends using a third party email provider such as SendGrid, this guide for sending email from Firebase functions with SendGrid could be useful.

Related