Registry / http-networking / imaplib2

imaplib2

JSON →
library3.6pypypi✓ verified 84d ago

imaplib2 is a threaded Python IMAP4 client library, compatible with Python 3.6+. Version 3.6 is the latest stable release. It is maintained by the Jazzband community and provides an alternative to the standard library's imaplib, with threading support and improved performance.

pip install imaplib2
INSTALL
IMPORT
SIG · IMAPLIB2
I
imaplib2
http-networkingpythonv3.6
Install
1.5s avg
Import
29ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.030s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.028s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

IMAP4
from imaplib2 import IMAP4
import imaplib2
Direct import of imaplib2 without using submodule will not expose IMAP4 class.

Connect to an IMAP server, login, select inbox, and search for all messages.

import os from imaplib2 import IMAP4 with IMAP4('imap.example.com') as M: M.login(os.environ['USER'], os.environ['PASS']) M.select() typ, data = M.search(None, 'ALL') print(data)
Debug
Known issues
deprecatedimaplib2 3.x drops support for SSL/TLS context parameters like `keyfile` and `certfile`. Use `ssl_context` instead.
fix
Replace `keyfile` and `certfile` arguments with `ssl.SSLContext` object passed to `IMAP4_SSL`.
affects: >=3.0
breakingIn version 3.x, the `IMAP4` class no longer supports direct SSL without using `IMAP4_SSL`. Plain `IMAP4` is for non-SSL connections only.
fix
Use `IMAP4_SSL` for SSL connections, not `IMAP4`.
affects: >=3.0
gotchaThe library is thread-safe but not fork-safe. Using `os.fork()` after creating an IMAP connection may lead to undefined behavior.
fix
Avoid forking after establishing an IMAP session. Reconnect in child processes if needed.
affects: all
Errors
Common errors & fixes
AttributeError: module 'imaplib2' has no attribute 'IMAP4'
Import statement is `import imaplib2` but the class is in submodules.
fix
Use `from imaplib2 import IMAP4` or `import imaplib2; imaplib2.IMAP4` (imaplib2 exposes IMAP4 as alias).
imaplib2.IMAP4.error: command SEARCH illegal in state NONAUTH
Trying to execute commands before login or after logout.
fix
Ensure you call `login()` or `authenticate()` before any mailbox commands.
imaplib2.IMAP4.abort: connection closed unexpectedly
Server timeout or network issue; library raises abort on connection loss.
fix
Implement reconnect logic. Use try/except and re-instantiate connection.
Upgrade
Version history
3.6latest on PyPI · released Jun 10, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
33 hits · last 30 days
node
32
OpenAI (training)
1
Resources