Search Here

Send Bulk Email From Python Using Google Cloud Console Gmail API

In this article, you will learn how to create Gmail Bot to send bulk emails using a python script. This bot uses Google Cloud Console Gmail API to send emails in bulk.
Send Bulk Email From Python Using Cloud Console Gmail API

How Bulk Email Sender Bot Works

To send an email using python script follow the below steps.
  • Go to https://console.cloud.google.com/getting-started and create a new project
  • Under this project create a Gmail API library
  • Set and create OAuth Consent Screen, to do this you must use https://mail.google.com/
  • Add Test User for your app
  • Generate OAuth ClientId (this "token" is the key thing, and later we are going to use this JSON in our python bot)
  • Below is the complete video tutorial to do all of the above stuff steps by step.


  • You have to download the "client_secret.json" file. Remember you can use any name of json file but in this tutorial you must rename the downloaded json file as "credentials.json" and put that file into the directory where your python script exists
  • Create a folder named Gmail Python Bot, this directory contains following files.
    • Python script
    • Text file containing email on each line
    • An excel file that will contain email information. In our case in this file we have two columns. The first column contains the link of blog post and the second one have description of blog post.

This python bot reads an email from a text file and selects 20 emails randomly. It will also read from an excel file and collect email messages, in our case this will collect blog post descriptions and link randomly from an excel file and send an emails to the recipients after  every 12 to 15 minutes. 

Send Bulk Email From Python Using Cloud Console Gmail API

Below is the complete code to send email from python using google cloud console Gmail API.

Post a Comment

0 Comments