Python email.header: encode internationalized email header values
Answer: The email.header module supplies a Header class for encoding header values that go beyond 7-bit ASCII.
Why this module still exists
RFC 2822 describes the email message format and assumes 7-bit ASCII only.
Language specific character sets can now be used in email messages.
The email package covers those later RFCs in email.header and email.charset.
You import Header from email.header when you need that encoding control.
Building and folding a Header
Optional s is the initial header value. If None, the initial header value is not set, and you can later append to the header with append method calls.
If you omit charset, us-ascii is used for the first value and as the default for later appends.
The default maximum line length is 78.
continuation_ws defaults to a single space and is prepended to continuation lines.
See also
Claims
- id: C1 claim: RFC 2822 assumes email uses only 7-bit ASCII. source: S1 evidence: "RFC 2822 is a specification written assuming email contains only 7-bit ASCII characters."
- id: C2 claim: Import Header from email.header. source: S1 evidence: "Import the Header class from the email.header module."
- id: C3 claim: The default maximum line length is 78. source: S2 evidence: "The default maxlinelen is 78"
- id: C4 claim: The constructor takes a continuation_ws parameter. source: S2 evidence: "continuation_ws=' '"
Sources
- [S1] email.header: Internationalized headers. Python Software Foundation. https://docs.python.org/3/library/email.header.html . License: PSF License Version 2. Accessed 2026-11-26.
- [S2] email.header documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/email.header.rst . License: PSF License Version 2. Accessed 2026-11-26.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, email.header: Internationalized headers; CPython, email.header documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, email.header: Internationalized headers; CPython, email.header documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.
Cite this
iinventedlight. 2026. "Python email.header: encode internationalized email header values." iinventedlight Library, iil:note:qmvj5t6g, version of 2026-11-26. https://iinventedlight.com/library/notes/python-email-header/. License: CC-BY-4.0.
@misc{iil_note_qmvj5t6g,
author = {{iinventedlight}},
title = {{Python email.header: encode internationalized email header values}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-26},
url = {https://iinventedlight.com/library/notes/python-email-header/},
note = {Permanent ID iil:note:qmvj5t6g. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-email-header.schema.json (schema; CC-BY-4.0)
- python-email-header.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-email-header.md.