Bulk emailing with Python

Harsha Siriwardana
2 min readFeb 10, 2022

Sending emails with certain content to a list of recipients can be easily achieved with the use of the ‘bcc’ feature of email providers. Each and every recipient will receive a copy of the same message.

But if you need to send completely new message to same set of people again we have to spend some time on it. So i though of creating simple script which will do this job and allow more flexibity.

Let’s see how we can do this.

Prerequisits

  1. you need a gmail account
  2. App password- read on how to generate app password using below link
  3. Python installed environment -if you want to download python use this

Please make sure you do not share this app password, which could lead to give access to others.

File Structure

folder structure

Let’s gone through the each file.

email-sender.py

input.json

This is where you provide your credentials, list of recipients and subject of email.

Content.txt

This is where you provide content of the email.

How to run the script

  1. Navigate to the folder, in our example it is “FolderName” using terminal
  2. run bellow commsnd

python3 email-sender.py

At the end you will get nice message on how many emails send sucessfully and how many failed.

Thanks for reading! (A few 👏 are always appreciated. 😀). Happy emailing :)

--

--