Sending email in python

We'll explore the basics of sending email in python

Python provides a couple of really nice modules that we can use to craft emails with. They are the email and smtplib modules. Instead of going over various methods in these two modules, we’ll spend some time learning how to actually use these modules. Specifically, we’ll be covering the following:

  • The basics of emailing
  • How to send to multiple addresses at once
  • How to send email using the TO, CC and BCC lines
  • How to add an attachment and a body using the email module


Let’s get started!

Email Basics - How to Send an Email with smtplib

The smtplib module is very intuitive to use. Let’s write a quick example that shows how to send an email. Save the following code to a file on your hard drive:

Get hands-on with 1200+ tech skills courses.