---
source: https://iinventedlight.com/library/notes/python-email-policy.md
title: "Python email.policy: control how the email package parses and generates messages"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, email.policy: Policy Objects; CPython, email.policy documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-email-policy"
tags: [python, email, policy, EmailPolicy, Compat32]
client: Librarian
sources:
  - id: S1
    title: "email.policy: Policy Objects"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/email.policy.html
    accessed: 2026-11-26
    license: "PSF License Version 2"
  - id: S2
    title: "email.policy documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/email.policy.rst
    accessed: 2026-11-26
    license: "PSF License Version 2"
---
# Python email.policy: control how the email package parses and generates messages
**Answer:** Policy objects let the email package change how messages are parsed and generated for different use cases.

## What a policy controls

A Policy object encapsulates attributes and methods that control the behavior of email package components during use.

You can pass a policy instance into email classes and methods when you need non-default behavior.

Every class in the email package has a default policy.

Parser helpers and the Message class use the Compat32 policy, through the pre-defined compat32 instance.

## EmailMessage, cloning, and future defaults

EmailMessage uses the EmailPolicy policy by default, through the pre-defined default instance.

A newly created Message or EmailMessage object takes on a policy.

When a parser creates the message, the policy passed into that parser becomes the policy of the created message.

Adding two policy objects is not commutative, so the order of the addends matters.

## See also

- [python-email](https://iinventedlight.com/library/notes/python-email/)
- [python-email-message](https://iinventedlight.com/library/notes/python-email-message/)
- [python-email-parser](https://iinventedlight.com/library/notes/python-email-parser/)

## Claims

- id: C1
  claim: Policy objects exist so the email package can cover very different use cases.
  source: S1
  evidence: "Policy objects give the email package the flexibility to handle all these disparate use cases."

- id: C2
  claim: A Message or EmailMessage acquires a policy when it is created.
  source: S1
  evidence: "When a Message or EmailMessage object is created, it acquires a policy."

- id: C3
  claim: Every email package class has a default policy.
  source: S2
  evidence: "There is a default policy used by all classes in the email package."

- id: C4
  claim: Combining policies with addition is not commutative.
  source: S2
  evidence: "This operation is not commutative"

## Sources

- [S1] email.policy: Policy Objects. Python Software Foundation. https://docs.python.org/3/library/email.policy.html . License: PSF License Version 2. Accessed 2026-11-26.

- [S2] email.policy documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/email.policy.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.policy: Policy Objects; CPython, email.policy documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
