Automation
Python Automation|Part 6 : Gmail Bulk Email Sending Automation|Python Web Automation|Python Selenium Automation
Introduction
Hey friends, in our last article we saw how to read an excel file in python using openpyxl module. Today we will learn how to send bulk emails using python selenium and smtplib module. This article is divided into two parts, In first part we will learn how to send emails using smtplib module and in the second part we will see how to send bulk emails using selenium. So, let’s get started.
Sending Emails Using SMTPLib Module: SMTP or Simple Mail Transfer Protocol allows you to send emails from your python script. It uses RFC 822 format for email headers. You can use any email ID as long as it is a valid email ID. Let’s see a simple example where we will send an email using gmail ID. For that you need to allow less secure apps on your gmail account by going into settings, if you don’t do that then you will get an error saying “smtplib.SMTPAuthenticationError: (535, b’5.7.8 Username and Password not accepted. Learn more atn5.7.8 https://support.google.com/mail/?p=InvalidCredentials q7sm5451329wmu.28 – gsmtp’)”
So, first of all go into your gmail settings and allow less secure apps or else you can use a different email service provider like yahoo, hotmail, etc which doesn’t have this security feature enabled by default. Now let’s write our python script: