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 create, update, delete, and write events:

Lets start,

Step 1:

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).

mkdir welcome-mail

code welcome-mail

Step 2:

Initialize your firebase project using the given command.

firebase init

cd functions

npm i nodemailer

Step 3:

This is how your index.js will look. We are using gmail to send mail. Replace

the email and password with yours.

Step 4:

Deploy your cloud function using the following command.

firebase deploy

Project Structure

get the complete project here

Step 5:

You need to allow less secure apps in your gmail account from here

Less secure apps

That’s all and you are ready to go

--

--

I am a Software Engineer @Walmart and instructor @Udemy, working on Blockchain, and Kubernetes. Get in touch: linktr.ee/adityajoshi12

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aditya Joshi

I am a Software Engineer @Walmart and instructor @Udemy, working on Blockchain, and Kubernetes. Get in touch: linktr.ee/adityajoshi12