2

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 ?

Tom3652
  • 2,540
  • 3
  • 19
  • 45
  • 1
    From an [issue](https://github.com/firebase/functions-samples/issues/39) in the same repository, it seems like you also need to enable `DisplayUnlockCaptcha` in your Gmail account in addition to enabling `lessSecureApp`. You can also check this [thread](https://stackoverflow.com/questions/51980436/) for additional things to try. Another behavior you might be seeing is that it works for some time and then fails, which is caused by Gmail’s sending [quota](https://github.com/firebase/functions-samples/tree/main/quickstarts/email-users#functions-code). – ErnestoC Jan 07 '22 at 21:44
  • Thanks for your comment ! It helps indeed as i know i can't use this API to send emails anyway because of the quota :) – Tom3652 Jan 08 '22 at 12:34

1 Answers1

0

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.

ErnestoC
  • 2,660
  • 1
  • 6
  • 19