Skip to Content
Python in a Nutshell, 3rd Edition
book

Python in a Nutshell, 3rd Edition

by Alex Martelli, Anna Ravenscroft, Steve Holden
April 2017
Intermediate to advanced content levelIntermediate to advanced
769 pages
21h 56m
English
O'Reilly Media, Inc.
Content preview from Python in a Nutshell, 3rd Edition

Chapter 21. Email, MIME, and Other Network Encodings

What travels on a network are streams of bytes, also known in networking jargon as octets. Bytes can, of course, represent text, via any of several possible encodings. However, what you want to send over the network often has more structure than just a stream of text or bytes. The Multipurpose Internet Mail Extensions (MIME) and other encoding standards bridge the gap by specifying how to represent structured data as bytes or text. While often originally designed for email, such encodings are also used in the web and many other networked systems. Python supports such encodings through many library modules, such as base64, quopri, and uu (covered in “Encoding Binary Data as ASCII Text”), and the modules of the email package (covered in “MIME and Email Format Handling”).

MIME and Email Format Handling

The email package handles parsing, generation, and manipulation of MIME files such as email messages, Network News (NNTP) posts, HTTP interactions, and so on. The Python standard library also contains other modules that handle some parts of these jobs. However, the email package offers a complete and systematic approach to these important tasks. We suggest you use email, not the older modules that partially overlap with parts of email’s functionality. email, despite its name, has nothing to do with receiving or sending email; for such tasks, see the modules poplib and smtplib, covered in “Email Protocols”. email deals with handling ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python in a Nutshell, 4th Edition

Python in a Nutshell, 4th Edition

Alex Martelli, Anna Martelli Ravenscroft, Steve Holden, Paul McGuire

Publisher Resources

ISBN: 9781491913833Errata Page