How I am building Email Notifications through Google API

Those who are following my blog might already know that I am building a Backup solution for my team and particularly Kishan who take backup and is spending around 30-60 minutes into this. ????.

Building BackupPro has been so much fun since I have heavily used ChatGPT to help me build the code and has helped me increase my speed like 3x faster.

In this Blog I am going to take you on my Journey where I am going to integrate Email Notification System for which I am going to use Gmail API.

Why Email Notification System?

Well anyone who knows me will know how much I am a fan of Automation it’s like magic for me. And here I am going to save a lot of time for my Team.

The current process is like.

  • Team takes Backup
    • Finding the opening the credentials files.
    • Logging into the PhpMyAdmin by copy pasting the username and password.
    • Navigation to the right database and then Exporting the DB.
    • Waiting for the Backup to download.
  • Writes and Update Email to the Seniors.
  • Take a small break to reset for next task.

Why an email notification system?

Well, anyone who knows me will know how much of a fan I am of automation. It’s like magic to me. And now, I have the opportunity to save a significant amount of time for my team.

The current process is as follows:

  1. The team takes a backup.
    • Finding and opening the credentials files.
    • Logging into PhpMyAdmin by copying and pasting the username and password.
    • Navigating to the correct database and exporting the DB.
    • Waiting for the backup to download.
  2. Writing and updating an email to the seniors.
  3. Taking a small break to reset for the next task.

With BackPro, we have almost automated the entire process, except for notifying the interested parties that the backup has been made.

Once the automation of email notifications is implemented, our process will be reduced from approximately 1 hour daily and around 24 hours of work monthly (which is equivalent to 8 days of work) to practically 1 minute daily.

This will save us 3 days’ worth of time every month. Isn’t this interesting?

What is the Design of this feature?

Outline.

  • I am already using Google API so I am not going to use SMTP or any other 3rd party API to send notifications.
  • Google’s Gmail API is what I will use, I would just have to enable it in the existing project.
  • I would also build a Email Template Designer inside the project that will help be build HTML Email for the user.

Building the Email Template Builder.

The Email Template builder will allow the user to draft the Email as he wants and there would be placeholders which will help in making dynamic.

Before we begin I need to decide.

  1. What Kind of Interface would I give to the users.
    Would it be DIY HTML where the user would be able to upload his own HTML Code or will there be a WYSIWYG editor.
  2. What Placeholders would be there.
  3. How would the interface look like.

What Kind of interface will we give to the users to design their Email Templates?

Well for this project I would not go for any fany WYSIWYG editor like TinyMCE or similar editors. I’ll keep it just HTML because my team is all technical and mostly the users of this BackupPro would be. But will keep a default template in place to make things easier.

What Placeholders would be there.

The placeholder part is quite simple, the end user would be interested in.

  • Where the Backup is?
  • At what time the Backup was taken
  • What was the Size of the Backup?
  • When will the next Backup Happen?

These are the things he would like to send.

How would the interface look like?

There would be another Menu in the right sidebar called “Email Settings”

Inside Email Settings there would be two tabs.

1. Email Notification Subscribers.
Here there would be a “Add Subscriber Interface” similar to how we have in the following layout.


2. Email Template.

Email template will be a big Textarea with the predefined template, Probably a preview button and a side section with all available placeholders.