14.1. The rfc822 Module

The term rfc822 refers to the standard for the header information used in Internet e-mail messages. The full specification can be found at http://www.ietf.org/rfcs/rfc0822.txt. The bulk of rfc822 is concerned with specifying the syntax for the headers that accompany the body of e-mail messages; headers such as from, to, subject, and so on. Python's rfc822 module takes a file object and puts as much of the content as it can parse into headers, according to the rules of rfc822.

The following program illustrates how the rfc822 module is used.

 CD-ROM reference=14001.txt """ Simple program to illustrate use of Python's rfc822 module """ import rfc822,StringIO email = """To: sean@digitome.com From: paul@digitome.com Subject: ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.