Send Welcome Mail to new user Using Firebase Cloud Functions
This article will help app/web developer using firebase as there backend solution to send any type of email to there users automatically using the cloud functions. You can send any type of mail using cloud functions.
To achieve this we will be using nodejs for writing cloud functions. And to make these emails automatically send we will be using the Cloud Firestore triggers. What it does is that it will trigger the cloud function on certain event on firestore. Cloud Firestore supports
Make a folder and name it welcome-mail, you can name it as you want. Open it in any text editor, in my case I am using vs code. open you terminal (Linux/Mac user) or Command Prompt(Windows user).
Initialize your firebase project using the given command.
npm i nodemailer
This is how your index.js will look. We are using gmail to send mail. Replace
the email and password with yours.
Deploy your cloud function using the following command.
get the complete project here
You need to allow less secure apps in your gmail account from here
That’s all and you are ready to go