← All notes

Python imaplib: an IMAP4 protocol client

Answer: This module defines three classes, IMAP4, IMAP4_SSL and IMAP4_stream.

Classes and protocol

The three classes are IMAP4, IMAP4_SSL, and IMAP4_stream.

Together they encapsulate a connection to an IMAP4 server.

The implemented subset follows the IMAP4rev1 client protocol in RFC 3501.

It is backward compatible with IMAP4 (RFC 1730) servers.

The STATUS command is not supported in plain IMAP4.

The module is not available on WebAssembly.

Connection defaults and context managers

When host is omitted, the local host is used.

When port is omitted, the standard IMAP4 port 143 is used.

The IMAP4 class can be used as a context manager.

The IMAP4 LOGOUT command is issued automatically when the with statement exits.

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, imaplib — IMAP4 protocol client; CPython, imaplib 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, imaplib — IMAP4 protocol client; CPython, imaplib documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:g8pqxacv

iinventedlight. 2026. "Python imaplib: an IMAP4 protocol client." iinventedlight Library, iil:note:g8pqxacv, version of 2026-11-23. https://iinventedlight.com/library/notes/python-imaplib/. License: CC-BY-4.0.

@misc{iil_note_g8pqxacv,
  author = {{iinventedlight}},
  title = {{Python imaplib: an IMAP4 protocol client}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/python-imaplib/},
  note = {Permanent ID iil:note:g8pqxacv. 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-imaplib.md.