Andromeda
Note

EZGmail Module (Python)

Definition

A third-party “usability wrapper” for the official Google Gmail API, designed to simplify sending and reading emails.

Why It Matters

The official Gmail API is a “technical thicket” that can stall a project for days. EZGmail allows a developer to bypass this complexity and add robust communication features to a script in minutes. It is a prime example of why abstraction is necessary for high-velocity software development: it lets you focus on the “What” (sending notifications) rather than the “How” (OAuth token management).

Core Concepts

import ezgmail

# Sending an email
ezgmail.send('recipient@example.com', 'Hello', 'Body of the email')

# Searching for messages
threads = ezgmail.search('from:boss')
print(f"Found {len(threads)} threads.")
  • Setup & Auth: Requires a credentials.json file from the Google Cloud Console. Running ezgmail.init() performs an OAuth Handshake to generate a persistent token.json.
  • Thread vs. Message Hierarchy:
    • GmailThread: Represents a conversation. Methods like unread() and search() return lists of these.
    • GmailMessage: Individual emails within a thread. Accessed via the thread.messages attribute.
  • Key Methods:
    • ezgmail.send(to, subject, body, [attachments]): Sends an email.
    • ezgmail.unread(): Retrieves all unread conversation threads.
    • ezgmail.search('query'): Uses standard Gmail search operators.
  • Attributes: message.subject, message.body, message.sender, message.timestamp.

Connected Concepts