How It Works
Quick Start
- AgentMail (Recommended)
- IMAP/SMTP (Self-Hosted)
Zero-config email — no IMAP/SMTP setup. Get an email address instantly.
1
Set API Key
2
Start Bot
Platform Comparison
Event-Driven Modes (AgentMail)
AgentMailBot supports 4 reception modes. Choose based on your latency and reliability needs.YAML Configuration
Python API
Webhook Verification
When usingmode: webhook, set AGENTMAIL_WEBHOOK_SECRET in production. An unset secret causes all inbound webhooks to be rejected with HTTP 401 (fail-closed).
Accepted signature headers: X-AgentMail-Signature, X-Webhook-Signature, X-Signature.
For local development without a real AgentMail webhook, set PRAISONAI_INSECURE_WEBHOOKS=true — never in production. See Webhook Verification.
Duplicate protection on retries
AgentMailBot derives one stable AgentMail Idempotency-Key per outbound send and reuses it across every retry (the outbound resilience layer retries up to 3× by default). If a send succeeds on AgentMail but the client times out, the retry is deduplicated at the provider — the recipient gets exactly one email.
The key is forwarded to AgentMail via the
Idempotency-Key header. AgentMail honours it for 24 hours. Reuse the same key within that window to guarantee the send is dedup’d.Inbox Lifecycle Management
AgentMailBot implements theEmailProtocol from the core SDK, enabling programmatic inbox creation:
Using as Agent Tools
Don’t need a full bot? Use email as one-shot agent tools — auto-detects backend from env vars:- AgentMail Backend
- Gmail / Outlook Backend
Shared Features
BothEmailBot and AgentMailBot share these capabilities:
- Auto-Reply Prevention: Detects
Auto-Submittedheaders and common bot addresses to prevent infinite loops. - Blocked Sender Filtering: Configurable via
BotConfig.blocked_users. - Email Address Extraction: Parses
"Name <email>"format consistently. - Session Isolation: Per-sender
AgentStatefor independent conversations. - Command Handling: Subject-based commands (e.g.,
START:,STOP:). - Thread Correlation:
In-Reply-ToandReferencesheaders maintained.
Capabilities Matrix
Configuration
Environment Variables
BotConfig Options
send_message Options (AgentMail)
Best Practices
Use Hybrid Mode for Production
Use Hybrid Mode for Production
mode: hybrid gives sub-second latency via WebSocket with a 60-second poll fallback to catch any missed messages. Best of both worlds.Use Dedicated App Passwords
Use Dedicated App Passwords
Never use your main account password. Generate a platform-specific App Password for the bot.
Configure Blocked Senders
Configure Blocked Senders
Use
BotConfig.blocked_users to exclude noreply addresses or known marketing domains.Use AgentMail for Multi-Tenant
Use AgentMail for Multi-Tenant
Need separate inboxes per customer? Use
AgentMailBot.create_inbox() to provision on demand.Related
Messaging Bots
All supported messaging platforms
Bot Commands
Register custom commands

