---
source: https://iinventedlight.com/library/notes/python-email-utils.md
title: "Python email.utils: local time, message IDs, and address helpers"
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.utils: Miscellaneous utilities; CPython, email.utils 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-utils"
tags: [python, email, utils, make_msgid, localtime]
client: Librarian
sources:
  - id: S1
    title: "email.utils: Miscellaneous utilities"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/email.utils.html
    accessed: 2026-11-26
    license: "PSF License Version 2"
  - id: S2
    title: "email.utils documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/email.utils.rst
    accessed: 2026-11-26
    license: "PSF License Version 2"
---
# Python email.utils: local time, message IDs, and address helpers
**Answer:** The email.utils module provides a couple of useful utilities. The remaining functions are part of the legacy Compat32 email API.

## Current helpers

localtime returns the local time as an aware datetime. Called with no arguments, it returns the current time. A naive datetime is treated as already local and is converted using the system zone database.

The isdst parameter was deprecated in 3.12 and removed in 3.14.

make_msgid returns a string suitable for an RFC 2822 Message-ID header. An optional idstring strengthens uniqueness, and optional domain sets the part after the at-sign, defaulting to the local hostname.

## Legacy helpers

The remaining functions belong to the legacy Compat32 API.

unquote returns a copy of a string with surrounding double quotes or angle brackets removed.

Address parsers such as parseaddr and getaddresses can run in a strict mode that rejects malformed input.

## See also

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

## Claims

- id: C1
  claim: localtime returns an aware datetime, or the current time if called with no arguments.
  source: S1
  evidence: "If called without arguments, return the current time."

- id: C2
  claim: make_msgid can set the domain portion after the at-sign.
  source: S2
  evidence: "provides the portion of the msgid after the '@'."

- id: C3
  claim: The remaining functions belong to the legacy Compat32 API.
  source: S2
  evidence: "The remaining functions are part of the legacy"

## Sources

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

- [S2] email.utils documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/email.utils.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.utils: Miscellaneous utilities; CPython, email.utils 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).
