Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Sending Emails Using Python (Summary)

You made it to the end of the video course! Whether you came here to learn how to send confirmation emails to users, enable support emails directly from your code, or send reminders to everyone on your email list, you now have the tools to do it.

In this video course, you learned how to:

  • Set up and configure new email services for access from Python.
  • Configure secure connections using .SMTP_SSL().
  • Use the email and smtplib libraries to send emails with text and HTML content, attachments, and personalization.
  • Manage email headers to set alternate reply-to addresses.
  • Use transactional email services to send mass emails.

Enjoy sending emails with Python!

Resources mentioned in this lesson:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

00:00 In the previous lesson, I discussed alternatives to Gmail and the Python standard library when dealing with mail. In this lesson, I’ll summarize the course and point you at a few other places you can dig in. The Simple Mail Transfer Protocol is one of the older protocols on the internet and specifies how to send email between machines.

00:19 You can use Python’s smtplib to connect to mail servers using SMTP and send mail. The EmailMessage helper class makes it easier to build more complex messages, including using multiple recipients, setting reply-to, CC, and BCC headers, adding alternate mail bodies like HTML, and using attachments.

00:41 Modern mail servers tend to use SSL encryption and authentication. The smtplib module handles this with a couple of extra lines of code. Exactly how you authenticate is provider-specific, though, so your mileage may vary.

00:56 There’s always more at Real Python. This course is based on a written tutorial. I took a slightly different approach, so if you want to see more examples, it might be worth checking out.

01:06 The tutorial also goes into a little more detail about alternate providers, including a listing of exactly which free plans each provides. To learn more about SSL and encryption, this course and tutorial cover how HTTPS works, which uses the same kind of techniques as those used for SMTP servers.

01:26 Or, to learn more about encoding, this comprehensive tutorial on bytes in Python covers all sorts of binary data, including the base64 encoding mechanism you saw me use here. That’s all for now.

01:39 I hope you enjoyed the course. Thanks for your attention.

Become a Member to join the conversation.