Skip to main content

API for managing your email

Project description

Email-Manager

Lightweight Python toolkit for working with email via IMAP (read/search) and SMTP (send), with optional LLM-enhanced workflows such as summarization, prioritization, task extraction, reply assistance, and MUCH MORE!

Email-Manager provides a clean separation of concerns between:

  • transport (IMAP/SMTP)
  • query building
  • assistant logic

📦 Installation

pip install email-management

✨ Features

  • IMAP + SMTP high-level convenience via EmailManager
  • Fluent IMAP builder via EasyIMAPQuery
  • Natural-language IMAP queries, email summarization, reply assistant, email analysis...

🧱 Core Components

Component Responsibility
EmailManager Coordinates SMTP & IMAP, handles sending, replying, forwarding, inbox triage
EasyIMAPQuery Fluent IMAP builder with optional NL search
EmailAssistant LLM entry point for summary, reply, task extraction, classification, etc.

Detailed component documentation is provided in:


🔧 Quick Start Example

from email_management.smtp import SMTPClient
from email_management.imap import IMAPClient
from email_management.auth import PasswordAuth
from email_assistant import EmailAssistant, EmailAssistantProfile
from email_manager import EmailManager

# Password Authentication
auth = PasswordAuth(username="you@example.com", password="secret_app_password")

# Or use OAuth2Auth (e.g. Gmail/Outlook with OAuth tokens).
# def token_provider():
#     # Must return a fresh OAuth2 access token string
#     return get_access_token_somehow()
# auth = OAuth2Auth(username="you@example.com", token_provider=token_provider)

imap = IMAPClient(host="imap.example.com", port=993, auth=auth)
smtp = SMTPClient(host="smtp.example.com", port=587, auth=auth)

mgr = EmailManager(imap=imap, smtp=smtp)

profile = EmailAssistantProfile(
    name="Alex",
    role="Support Engineer",
    company="ExampleCorp",
    tone="friendly",
)

assistant = EmailAssistant(profile=profile)

📨 Searching & Fetching Email

IMAP operations can be performed directly:

msgs = mgr.fetch_latest(unseen_only=True, n=20)

Or via fluent IMAP builder:

q = mgr.imap_query().from_any("alerts@example.com").recent_unread(3)
msgs = q.fetch()

Natural-language searches are also supported:

query, info = assistant.search_emails(
    "find unread security alerts from Google last week",
    provider="openai",
    model_name="gpt-4.1",
    manager=mgr,
)
msgs = query.fetch()

🤖 Summarization, Classification & Replies

summary, meta = assistant.summarize_email(
    message=msgs[0],
    provider="openai",
    model_name="gpt-4.1",
)

reply_text, meta = assistant.generate_reply(
    reply_context="Confirm resolution and next steps",
    message=msgs[0],
    provider="openai",
    model_name="gpt-4.1",
)

Utility tasks include:

  • prioritize_emails()
  • classify_emails()
  • generate_follow_up()
  • extract_tasks()
  • summarize_thread()
  • detect_phishing()
  • evaluate_sender_trust()

🧰 EmailManager Overview

Supports:

  • Sending & composing
  • Drafts
  • Reply / Reply-all
  • Forwarding
  • Folder operations (move, copy, delete)
  • Flag operations (seen, answered, flagged, etc.)
  • Thread fetching
  • Unsubscribe helpers
  • Health checks

Example:

mgr.reply(
    original=msgs[0],
    body="Thanks! We'll follow up shortly.",
)

🗂 Documentation Structure

This README covers overall usage. Focused guides are in:


🪪 License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

email_management-0.1.4.tar.gz (71.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

email_management-0.1.4-py3-none-any.whl (67.3 kB view details)

Uploaded Python 3

File details

Details for the file email_management-0.1.4.tar.gz.

File metadata

  • Download URL: email_management-0.1.4.tar.gz
  • Upload date:
  • Size: 71.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for email_management-0.1.4.tar.gz
Algorithm Hash digest
SHA256 a25c0ec16797abbba240508999bdab7a51b4defae548fe39ec00dfaa908b6c2d
MD5 42a0fb595ac5fe56c3a4a2c5f30ab761
BLAKE2b-256 ba4d53f367c62b8457b2e3d5c9828038daff789bcf14865b2c9e62edba45db47

See more details on using hashes here.

File details

Details for the file email_management-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for email_management-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9051fa27704b4f30a7f8699a2fceea3e4679d4a5c23e88bda1a5e3d9c1b5d6ca
MD5 67ef2e8967b0e6149f23626a1f1a9ddc
BLAKE2b-256 a87ffa82119cb50174339b7c8e0c631acdb9d146acf62a61ba27ee2616906a9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page