LangChain + AgentMail
Official AgentMail integration for LangChain. Give your AI agents the ability to create email inboxes, send and receive emails, and automate email-based workflows like OTP verification.
Install
pip install langchain-agentmail
Quick Start
from langchain_agentmail import AgentMailToolkit
# Uses AGENTMAIL_API_KEY env var by default
toolkit = AgentMailToolkit()
tools = toolkit.get_tools()
Create an Inbox
result = tools[0].invoke({"name": "test-inbox"}) # CreateInbox
print(result) # {"inbox_id": "...", "email": "..."}
Send and Read Emails
# Send an email
tools[1].invoke({"to": "user@example.com", "subject": "Hello", "body": "Hi there!", "from": "inbox_abc123"})
# Wait for a reply (blocks up to 60s)
msg = tools[6].invoke({"inbox_id": "inbox_abc123", "timeout": 60})
Use with a LangGraph Agent
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from langchain_agentmail import AgentMailToolkit
toolkit = AgentMailToolkit()
agent = create_react_agent(ChatOpenAI(model="gpt-4o-mini"), toolkit.get_tools())
result = agent.invoke({"messages": [{"role": "user", "content": "Create an inbox and wait for a verification email"}]})
See example.py for a full OTP-automation agent.
Environment Variables
| Variable | Description |
|---|---|
AGENTMAIL_API_KEY |
Your AgentMail API key (required) |
Tools
| Tool | Description |
|---|---|
CreateInbox |
Create a new email inbox |
SendEmail |
Send an email |
ListMessages |
List messages in an inbox |
GetMessage |
Get a single message by ID |
ReplyToEmail |
Reply to a message |
ForwardEmail |
Forward a message |
WaitForMessage |
Block until a new message arrives |
SearchMessages |
Search messages by query |
CreateLabel |
Create an organizational label |
ApplyLabel |
Apply a label to a message |
DeleteInbox |
Delete an inbox permanently |
License
MIT
Release files for langchain-agentmail 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_agentmail-0.1.0.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_agentmail-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.8 kB
Release files / langchain_agentmail-0.1.0.tar.gz
| Download URL | langchain_agentmail-0.1.0.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3dff2b9b8d71c5ce26f2f46ee3f114aeb1c76a2ff1eb1a62f6155601fc578ee
|
|
BLAKE2b-256 checksum How to use checksums |
3ee6f8bf2850caf3a0b63e86502600389668b83ee360a45d4e6a496890e5652b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / langchain_agentmail-0.1.0-py3-none-any.whl
| Download URL | langchain_agentmail-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
117c58fd45b945fe2c9da81a6edb1db3d5afd3a7965d17910a55d8f1a2bb8c0e
|
|
BLAKE2b-256 checksum How to use checksums |
89e17e54c0ba12b15419a884b0b32c58a963d08bb9c60df1bac351d82734dfb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|