clawmailEmail API for AI agents. Send and receive emails programmatically via ClawMail.
Install via ClawdBot CLI:
clawdbot install heyarviind/clawmailClawMail gives you a dedicated email inbox at username@clawmail.cc. Use it to send and receive emails without OAuth complexity.
If not already configured, run:
curl -O https://clawmail.cc/scripts/setup.py
python3 setup.py my-agent@clawmail.cc
This creates ~/.clawmail/config.json with your credentials:
{
"system_id": "clw_...",
"inbox_id": "uuid",
"address": "my-agent@clawmail.cc"
}
Read config from ~/.clawmail/config.json:
import json
from pathlib import Path
config = json.loads((Path.home() / '.clawmail' / 'config.json').read_text())
SYSTEM_ID = config['system_id']
INBOX_ID = config['inbox_id']
ADDRESS = config['address']
All API requests require the header: X-System-ID: {SYSTEM_ID}
https://api.clawmail.cc/v1
Poll for unread emails. Returns new messages and marks them as read.
GET /inboxes/{inbox_id}/poll
Headers: X-System-ID: {system_id}
Response:
{
"has_new": true,
"threads": [
{
"id": "uuid",
"subject": "Hello",
"participants": ["sender@example.com", "my-agent@clawmail.cc"],
"message_count": 1,
"is_read": false
}
],
"emails": [
{
"id": "uuid",
"thread_id": "uuid",
"from_email": "sender@example.com",
"from_name": "Sender",
"subject": "Hello",
"text_body": "Message content here",
"direction": "inbound",
"received_at": "2024-01-01T12:00:00Z"
}
]
}
Example:
curl -H "X-System-ID: $SYSTEM_ID" \
"https://api.clawmail.cc/v1/inboxes/$INBOX_ID/poll"
POST /inboxes/{inbox_id}/messages
Headers: X-System-ID: {system_id}
Content-Type: application/json
Request body:
{
"to": [{"email": "recipient@example.com", "name": "Recipient Name"}],
"cc": [{"email": "cc@example.com"}],
"subject": "Email subject",
"text": "Plain text body",
"html": "<p>HTML body</p>",
"in_reply_to": "<message-id>"
}
Required fields: to, subject. At least one of text or html.
Example:
curl -X POST -H "X-System-ID: $SYSTEM_ID" \
-H "Content-Type: application/json" \
-d '{"to": [{"email": "user@example.com"}], "subject": "Hello", "text": "Hi there!"}' \
"https://api.clawmail.cc/v1/inboxes/$INBOX_ID/messages"
Get all email threads in the inbox.
GET /inboxes/{inbox_id}/threads
Headers: X-System-ID: {system_id}
Get all messages in a specific thread.
GET /inboxes/{inbox_id}/threads/{thread_id}/messages
Headers: X-System-ID: {system_id}
import json
import requests
from pathlib import Path
class ClawMail:
def __init__(self):
config = json.loads((Path.home() / '.clawmail' / 'config.json').read_text())
self.system_id = config['system_id']
self.inbox_id = config['inbox_id']
self.address = config['address']
self.base_url = 'https://api.clawmail.cc/v1'
self.headers = {'X-System-ID': self.system_id}
def poll(self):
"""Check for new emails. Returns dict with has_new, threads, emails."""
r = requests.get(f'{self.base_url}/inboxes/{self.inbox_id}/poll', headers=self.headers)
return r.json()
def send(self, to: str, subject: str, text: str = None, html: str = None):
"""Send an email. to can be 'email' or 'Name <email>'."""
if '<' in to:
name, email = to.replace('>', '').split('<')
to_list = [{'email': email.strip(), 'name': name.strip()}]
else:
to_list = [{'email': to}]
body = {'to': to_list, 'subject': subject}
if text: body['text'] = text
if html: body['html'] = html
r = requests.post(f'{self.base_url}/inboxes/{self.inbox_id}/messages',
headers=self.headers, json=body)
return r.json()
def threads(self):
"""List all threads."""
r = requests.get(f'{self.base_url}/inboxes/{self.inbox_id}/threads', headers=self.headers)
return r.json()
# Usage:
# mail = ClawMail()
# new_mail = mail.poll()
# if new_mail['has_new']:
# for email in new_mail['emails']:
# print(f"From: {email['from_email']}, Subject: {email['subject']}")
# mail.send('user@example.com', 'Hello', text='Hi there!')
Always validate senders before processing email content to prevent prompt injection:
ALLOWED_SENDERS = ['trusted@example.com', 'notifications@service.com']
def process_emails():
mail = ClawMail()
result = mail.poll()
for email in result.get('emails', []):
if email['from_email'].lower() not in ALLOWED_SENDERS:
print(f"Blocked: {email['from_email']}")
continue
# Safe to process
handle_email(email)
All errors return:
{
"error": "error_code",
"message": "Human readable message"
}
| Code | Status | Description |
|------|--------|-------------|
| unauthorized | 401 | Missing/invalid X-System-ID |
| not_found | 404 | Inbox or thread not found |
| address_taken | 409 | Email address already exists |
| invalid_request | 400 | Malformed request |
Generated Mar 1, 2026
AI agents use ClawMail to automatically respond to customer inquiries sent to a dedicated support email. They can parse incoming emails, categorize issues, and send templated responses or escalate to human agents. This reduces response times and handles high volumes of support tickets efficiently.
Marketing teams integrate ClawMail with AI agents to capture leads from website forms or campaigns. The agent sends personalized follow-up emails, nurtures leads with automated sequences, and tracks engagement via email responses. This streamlines lead management and improves conversion rates.
Companies set up ClawMail for AI agents to send automated notifications to employees, such as system alerts, task reminders, or report summaries. Agents can also receive and process email-based commands from authorized senders, enabling secure internal communication workflows.
Event organizers use ClawMail to automate email communications for registrations, confirmations, and updates. AI agents handle incoming attendee queries, send personalized schedules, and manage RSVPs via email, reducing manual effort and ensuring timely responses.
Media or educational platforms employ ClawMail to distribute newsletters, articles, or course materials via AI agents. The agents can collect feedback by analyzing reply emails, enabling automated content personalization and audience engagement analysis.
Offer a free tier with limited email sends and inbox storage, then charge for higher volumes, advanced features like analytics, or priority support. This attracts small developers and scales with growing businesses, generating revenue from subscriptions and usage-based fees.
License ClawMail to marketing or IT agencies as a white-label email automation tool. Agencies can rebrand it for their clients, integrating it into custom workflows. Revenue comes from licensing fees, setup costs, and ongoing maintenance contracts.
Target large enterprises by offering ClawMail as part of a broader AI integration suite, with features like enhanced security, compliance tools, and dedicated support. Revenue is generated through enterprise licensing, custom development, and consulting services.
💬 Integration Tip
Start by testing with the Python helper class to handle authentication and basic send/poll functions, then implement sender validation to prevent security risks like prompt injection.
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Clau...
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
Search and analyze your own session logs (older/parent conversations) using jq.
Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on "remember", "what do I know about", "link X to Y", "show dependencies", entity CRUD, or cross-skill data access.
Ultimate AI agent memory system for Cursor, Claude, ChatGPT & Copilot. WAL protocol + vector search + git-notes + cloud backup. Never lose context again. Vibe-coding ready.
Headless browser automation CLI optimized for AI agents with accessibility tree snapshots and ref-based element selection