How ikvk/imap_tools works
Project type and purpose
• This is an open-source Python library (“imap_tools”) that provides a high-level API over the standard imaplib module for interacting with IMAP mail servers.
• Its purpose is to simplify mailbox operations (search, fetch, folders, flags, IDLE) and message parsing (headers, text/html bodies, attachments) without external dependencies.
File structure
• Top-level:
• setup.py, MANIFEST.in, LICENSE – packaging/metadata
• README.rst – project overview
• docs/ – design notes, RFC references, release notes
• examples/ – sample usage scripts
• tests/ – unit tests and test fixtures (raw .eml files and expected parsed data)
• Core code in imap_tools/:
• mailbox.py, idle.py, folder.py – high-level clients and sub-managers
• query.py – IMAP search criteria builder (AND, OR, NOT, UidRange)
• message.py – MailMessage, MailAttachment, parsing logic
• imap_utf7.py – mailbox name encoding
• utils.py – helpers (encoding, parsing)
• consts.py – constants (flags, sort criteria)
• errors.py – custom exception types
README for additional insights
• Main API: MailBox, MailBoxTls, MailBoxUnencrypted classes with context-manager and methods: fetch, uids, numbers, copy/move/delete/flag/append, folder operations, idle operations.
• Describes method parameters, query builder usage, data model (MailMessage attributes).
• Highlights no external dependencies, Python 3.8+, tested against IMAP4.1 & RFC-2822.