How charlierguo/gmail works
Project type and purpose
• This is a client-side Python library (“GMail for Python”) that wraps Google GMail’s functionality (search, read, send, label, archive, delete, etc.).
• It is not a full-stack application or service; it is an open-source tool intended to be embedded in other Python applications and scripts.
File structure
• Top-level files:
• README.md, LICENSE, setup.py – standard package metadata and installer
• gmail/ – the core Python package
• Within gmail/:
• gmail.py – the main Gmail client class (authentication, session management)
• mailbox.py – the Mailbox abstraction (inbox, labels, queries)
• message.py – the Message abstraction (headers, bodies, attachments, actions)
• utf.py, utils.py – helper modules (encoding, common utilities)
• exceptions.py – custom exception types (e.g. AuthenticationError)
• No frontend/UI; no database – the “backend” is the external Google GMail servers (IMAP/SMTP or HTTP API).
• setup.py indicates it’s installable via pip once packaged.
README for additional insights
• The library supports two authentication modes: simple username/password (IMAP login) and OAuth2.
• Exposes a fluent, object-oriented API:
• Gmail.login(...) → returns a session object
• session.inbox().mail(...) → returns a list of Message stubs
• message.fetch() → populates body, attachments, labels
• message.read()/delete()/archive()/add_label() → state-modifying calls