Email and MIME Modules

email.header

Legacy helpers for encoding and decoding non-ASCII header text using encoded words. decode_header returns fragments with their encodings, and make_header combines them. Modern EmailMessage with an appropriate policy usually handles header encoding automatically.

Formal Syntax & Structure

python syntaxpython
import email.header

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from email.header import decode_header, make_headerparts = decode_header("=?utf-8?b?Y2Fmw6k=?=")print(str(make_header(parts)))
Python Reference