LangChain integration for retrieving emails from IMAP servers
Project description
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:
Falsefor self-signed certs (not for production)
Supports Gmail, Outlook, Yahoo, custom IMAP servers.
API Reference
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_imap-0.1.0.tar.gz.
File metadata
- Download URL: langchain_imap-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.11 Linux/6.14.0-33-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0f31782e8ae31d2128415ac7c639ff44a3f4cfd9e47d3f307194039abdffd02
|
|
| MD5 |
81aab89218dd373bbb76c36f8cc9917c
|
|
| BLAKE2b-256 |
af5d022ce10baa21d389072e8a5c4f32d68eb5b655cbeb66fb910337d652a20e
|
File details
Details for the file langchain_imap-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_imap-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.11 Linux/6.14.0-33-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a74d5130d8ca6dec823f5cc1170e4de634373456cdb2bacebec74c2b98f2fc59
|
|
| MD5 |
c97c66ec07a3f6c53b17c85126e36f49
|
|
| BLAKE2b-256 |
ea01816a352f60c2895281183c7997c471cd63556d046d657cfef887af04099e
|