← All notes

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

Sources

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

Permanent ID: iil:note:qmvj5t6g

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.},
}

Markdown

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.

All artifact files (JSON index)

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.