Sitemap
TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

How to Send Emails Using Python

3 min readJul 13, 2021

--

Press enter or click to view image in full size
Source: https://unsplash.com/photos/3Mhgvrk4tjM

In this tutorial, I will show you multiple ways of sending emails using Python. This can be useful in many projects or cases where you need to share any type of information to different people in a fast, easy and secure way.

The traditional way: SMTPLIB

The library is the most popular one when it comes to sending email with Python. It creates a Simple Mail Transfer Protocol (SMTP) session object that can be used to send mail to any internet machine.

Before sending an email using this module, you need to change a setting in your email account. Indeed, you need to “enable access to less secure apps” in the email you will be using as the sender. More on this here: https://support.google.com/accounts/answer/6010255#zippy=%2Cif-less-secure-app-access-is-on-for-your-account

Once this is done, here is the code that will allow you to send a very simple email in no time.

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.