{"id":23879,"library":"imaplib2","title":"imaplib2","description":"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.","status":"active","version":"3.6","language":"python","source_language":"en","source_url":"https://github.com/jazzband/imaplib2","tags":["IMAP","email","threaded","client","imaplib"],"install":[{"cmd":"pip install imaplib2","lang":"bash","label":"Install imaplib2"}],"dependencies":[],"imports":[{"note":"Direct import of imaplib2 without using submodule will not expose IMAP4 class.","wrong":"import imaplib2","symbol":"IMAP4","correct":"from imaplib2 import IMAP4"}],"quickstart":{"code":"import os\nfrom imaplib2 import IMAP4\n\nwith IMAP4('imap.example.com') as M:\n    M.login(os.environ['USER'], os.environ['PASS'])\n    M.select()\n    typ, data = M.search(None, 'ALL')\n    print(data)","lang":"python","description":"Connect to an IMAP server, login, select inbox, and search for all messages."},"warnings":[{"fix":"Replace `keyfile` and `certfile` arguments with `ssl.SSLContext` object passed to `IMAP4_SSL`.","message":"imaplib2 3.x drops support for SSL/TLS context parameters like `keyfile` and `certfile`. Use `ssl_context` instead.","severity":"deprecated","affected_versions":">=3.0"},{"fix":"Use `IMAP4_SSL` for SSL connections, not `IMAP4`.","message":"In version 3.x, the `IMAP4` class no longer supports direct SSL without using `IMAP4_SSL`. Plain `IMAP4` is for non-SSL connections only.","severity":"breaking","affected_versions":">=3.0"},{"fix":"Avoid forking after establishing an IMAP session. Reconnect in child processes if needed.","message":"The library is thread-safe but not fork-safe. Using `os.fork()` after creating an IMAP connection may lead to undefined behavior.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'3.6':13,15 'altern':31 'client':8,47 'communiti':27 'compat':10 'email':45 'imap':44 'imap4':7 'imaplib':37,48 'imaplib2':1,2 'improv':42 'jazzband':26 'latest':18 'librari':9,35 'maintain':23 'perform':43 'provid':29 'python':6,12 'releas':20 'stabl':19 'standard':34 'support':40 'thread':5,39,46 'version':14","created_at":"2026-05-01T08:10:06.656443+00:00","updated_at":"2026-05-01T08:10:06.656443+00:00","problems":[{"fix":"Use `from imaplib2 import IMAP4` or `import imaplib2; imaplib2.IMAP4` (imaplib2 exposes IMAP4 as alias).","cause":"Import statement is `import imaplib2` but the class is in submodules.","error":"AttributeError: module 'imaplib2' has no attribute 'IMAP4'"},{"fix":"Ensure you call `login()` or `authenticate()` before any mailbox commands.","cause":"Trying to execute commands before login or after logout.","error":"imaplib2.IMAP4.error: command SEARCH illegal in state NONAUTH"},{"fix":"Implement reconnect logic. Use try/except and re-instantiate connection.","cause":"Server timeout or network issue; library raises abort on connection loss.","error":"imaplib2.IMAP4.abort: connection closed unexpectedly"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.6","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/jazzband/imaplib2","docs":null,"changelog":null,"pypi":"https://pypi.org/project/imaplib2/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}