Email and MIME Modules
email.parser
Converts serialized messages to message objects through Parser, BytesParser and incremental feed parsers. Specify policy explicitly to select modern EmailMessage behavior. Malformed input may produce defects rather than exceptions; impose size limits before parsing untrusted messages.
Formal Syntax & Structure
python syntaxpython
import email.parserReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from email.parser import BytesParserfrom email import policymessage = BytesParser(policy=policy.default).parsebytes(b"Subject: Note\r\n\r\nReady")print(message.get_content())