Skip to main content

langchain-imap

This package provides the ImapRetriever for LangChain, enabling search and retrieval of emails from IMAP servers as LangChain Document objects.

Installation

pip install -U langchain-imap

For full document processing (DOCX, PPTX, etc.) with docling:

pip install "langchain-imap[docling]"

Quickstart

from langchain_imap import ImapConfig, ImapRetriever

config = ImapConfig(
    host="imap.gmail.com",
    port=993,
    user="your-email@gmail.com",
    password="your-app-password",  # Use app password for Gmail
    ssl_mode="ssl",
)

retriever = ImapRetriever(config=config, k=10)

# Search emails using IMAP syntax
docs = retriever.invoke('SUBJECT "urgent"')
for doc in docs:
    print(doc.page_content)  # Formatted email content

Attachment Handling

Three modes:

  • "names_only" (default): List attachment names
  • "text_extract": Extract text from PDFs and plain text attachments
  • "full_content": Full extraction using docling from office documents (requires [docling] extra)

Use in Chains

Integrate with LLMs for QA over emails. See the documentation notebook for examples.

Configuration

  • auth_method: "login" (default), supports others
  • ssl_mode: "ssl" (default), "starttls", "plain"
  • verify_cert: False for self-signed certs (not for production)

Supports Gmail, Outlook, Yahoo, custom IMAP servers.

API Reference

ImapRetriever

Metadata

Release files for langchain-imap 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-imap 0.1.0
File Size Uploaded
langchain_imap-0.1.0.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-imap 0.1.0
File Interpreter ABI Platform
langchain_imap-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / langchain_imap-0.1.0.tar.gz

Download URL langchain_imap-0.1.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e0f31782e8ae31d2128415ac7c639ff44a3f4cfd9e47d3f307194039abdffd02
BLAKE2b-256 checksum
How to use checksums
af5d022ce10baa21d389072e8a5c4f32d68eb5b655cbeb66fb910337d652a20e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.12.11 Linux/6.14.0-33-generic

Release files / langchain_imap-0.1.0-py3-none-any.whl

Download URL langchain_imap-0.1.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a74d5130d8ca6dec823f5cc1170e4de634373456cdb2bacebec74c2b98f2fc59
BLAKE2b-256 checksum
How to use checksums
ea01816a352f60c2895281183c7997c471cd63556d046d657cfef887af04099e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.12.11 Linux/6.14.0-33-generic

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page