O'Reilly logo

Automate it! - Recipes to upskill your business by Chetan Giridhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

E-mail encryption

E-mail is prone to disclosure of information. Most e-mails are currently transmitted in clear text format. E-mail encryption involves encrypting or disguising content of the e-mail so that the content is read by the intended recipients. Always remember that security is of prime importance when dealing with e-mails. Let's see how we can encrypt e-mails with Python.

Getting ready

We looked at sending a basic e-mail in the previous recipe, but what's the starttls() method? How does e-mail encryption work? We will get answers to these questions in this section.

How to do it...

  1. Let's start by opening our favorite editor and typing in the following code snippet:
     import smtplib server = smtplib.SMTP('smtp.gmail.com', 587) try: server.set_debuglevel(True) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required