If you're using Openclaw, one of the first things to consider is how your agent will handle email.
The two most common paths are:
- Connect Openclaw to Gmail using OAuth or IMAP.
- Use a dedicated agent email service like AgentMail.
Both options fit different situations. This guide will help you choose based on needs, scale, and budget.
What is Openclaw?
Before reviewing email options, here's a quick recap of Openclaw.
Openclaw is an open-source, self-hosted AI agent framework. It acts like a personal AI assistant with deep access to your system. You can think of it as your own AI employee that can:
- Communicate across WhatsApp, Telegram, Discord, Slack, Signal, iMessage, and email.
- Access your system - browse the web, read/write files, run shell commands.
- Remember everything - persistent long-term memory stored locally.
- Learn new skills - an extensible ecosystem of community-built skills.
- Work proactively - monitor conditions, suggest optimisations, run recurring tasks.
Openclaw runs fully on your device (macOS, Windows, Linux, or remote servers), so your data stays local and private.
The email challenge: Openclaw agents need email to interact with the outside world. This includes signing up for services, getting verification codes, handling customer support, working with other agents, and more.
Option 1: Gmail for Openclaw Agents
How It Works
You can connect your Openclaw agent to Gmail in two ways:
1. OAuth Integration (Recommended for full access)
During Openclaw's setup, you can authenticate with Google and grant your agent access to Gmail, Calendar, Drive, Docs, and Sheets. This involves:
- Creating a Google Cloud project
- Enabling Gmail API
- Setting up the OAuth consent screen
- Creating OAuth credentials
- Granting permissions to your agent
Setup complexity: Medium to High (requires Google Cloud Console navigation)
2. Himalaya CLI
The easiest way to connect Openclaw to Gmail is using the Himalaya skill available on ClawHub. Himalaya is a command-line email client that simplifies email interaction for Openclaw agents.
Installation options (recommended in order of safety):
# Option 1: Homebrew (macOS/Linux)
brew install himalaya
# Option 2: Nix
nix-env -i himalaya
# Option 3: Download pre-built binary
# Visit https://github.com/pimalaya/himalaya/releases
# Download for your OS and place in your PATH
For other installation methods, see the Himalaya installation guide.
Configuration Setup
Run the interactive wizard to set up an account:
himalaya account configure
Himalaya handles IMAP/SMTP configuration automatically and provides a clean interface for your agent to read and send emails through Gmail.
Setup complexity: Low
Alternative: Direct IMAP with App Password
If you prefer manual configuration, you can use Gmail's IMAP protocol directly:
- Enable 2-Step Verification on your Google Account
- Generate an App Password for "Mail"
- Configure Openclaw with IMAP settings (
imap.gmail.com:993) - Use SMTP for sending (
smtp.gmail.com:465or:587)
Setup complexity: Medium
Pros of Using Gmail
✅ Familiar and trusted - You already know how Gmail works
✅ Established infrastructure - 99.9% uptime, robust spam filtering
✅ Free for personal use - No cost for basic Gmail accounts
✅ Integration with Google ecosystem - Calendar, Drive, Docs all work together
✅ Generous storage - 15GB free (shared across Google services)
✅ Mobile access - Check your agent's inbox from the Gmail app
Cons of Using Gmail
❌ Risk of getting banned - Gmail can detect automation patterns and ban your account, causing you to lose all your data
❌ Manual inbox creation - Each inbox requires manual Google Account setup
❌ OAuth complexity - Hard to configure, requires Google Cloud Console setup
❌ Per-user pricing - Google Workspace costs between $6-18 inbox/month
❌ Send limits - 500 emails/day (free), 2,000/day (Workspace)
❌ Rate limits - 250 quota units/second per user, daily limits
❌ Not designed for agents - Often fails when sending emails or creating inboxes at scale
❌ Scaling challenges - Managing 10+ agent inboxes gets expensive and complex
Example cost for 5 agents: 5 agents × $12/month = $60/month (using Google Workspace Business Standard plan)
When Gmail Makes Sense
Gmail is the right choice if you:
- Already pay for Google Workspace for your business.
- Can handle some risk of getting inbox banned - best for ephemeral use cases where email doesn't need to persist
- Don't need to create inboxes programmatically.
Option 2: AgentMail for Openclaw Agents
How It Works
AgentMail is an API-first email platform built specifically for AI agents. Instead of adapting a human email service, it's designed from the ground up for autonomous systems.
Setup process:
- Sign up at agentmail.to
- Get your API key
- Install AgentMail SDK:
npm install agentmail - Create inboxes programmatically via API.
- Set up webhooks for real-time email processing.
Setup complexity: Low
Pros of Using AgentMail
✅ API-first design - Built for programmatic control
✅ Programmatic inbox creation - Spin up thousands of inboxes via API
✅ Simple authentication - API key, no OAuth flows
✅ Built-in webhooks - Real-time email event processing
✅ No rate limits (within reason) - Designed for high-volume automation
✅ Custom domains - Use your own domain for professional emails
✅ Semantic search - AI-powered inbox search and context retention
✅ Structured data extraction - Parse emails intelligently
✅ Perfect for testing - Create/destroy test inboxes on demand
Cons of Using AgentMail
❌ Newer service - Less established than Gmail
❌ Learning curve - Requires familiarity with APIs/how to use
❌ No mobile app - Access via API only (though you could build one)
❌ Less familiar - Not the Gmail interface you know, not as robust
Pricing Breakdown
AgentMail is built for scale and charges significantly less than traditional email providers:
| Plan | Price/Month | Inboxes | Emails/Month | Storage | Custom Domains |
|---|---|---|---|---|---|
| Free | $0 | 3 | 3,000 | 3 GB | - |
| Developer | $20 | 10 | 10,000 | 10 GB | 10 |
| Startup | $200 | 150 | 150,000 | 150 GB | 150 |
| Enterprise | Custom | Custom | Custom | Custom | Custom |
All plans include:
- Webhooks, threads, labels, attachments
- DKIM, SPF, DMARC authentication
- TypeScript SDK and MCP Server
- Email support (Developer tier and above)
When AgentMail Makes Sense
AgentMail is the right choice if you:
- Want a reliable inbox that has no risk of getting banned or flagged
- Need to create inboxes programmatically.
- Want easily configurable webhooks and websockets for real-time email processing.
- Want to configure custom domains programmatically via API
- Need high email volume with looser rate limits (thousands per day).
- Doing QA testing with automated signups.
- Want friendly prices for scaling instead of per-user fees.
- Building multi-tenant platforms which require dedicated inboxes per your users, customers, sessions, etc.
Feature Comparison
| Feature | Gmail | AgentMail |
|---|---|---|
| Inbox Creation | Manual (Google Account required) | Programmatic (API call) |
| Authentication | OAuth (requires human interaction) | API Key (simple) |
| Pricing Model | Per user/month | Usage-based |
| Email Limits | 500-2,000/day | High (designed for automation) |
| API Rate Limits | 250 units/sec per user | Generous (built for agents) |
| Webhooks | Not built-in (requires polling or Pub/Sub) | Built-in, real-time |
| Custom Domains | Yes (via Google Workspace) | Yes (on paid plans) |
| Mobile Access | Gmail app | API only |
| Deliverability | Excellent (Gmail reputation) | Good (SPF, DKIM, DMARC) |
| Storage | 15GB-5TB (depending on plan) | Unlimited message history |
| Semantic Search | Basic search | AI-powered semantic search |
| Thread Management | Manual | Automatic with context |
| Attachment Handling | Standard | Structured extraction |
| Setup Complexity | Medium-High (OAuth) | Low (API key) |
| Best For | 1-2 personal agents | 3+ agents, production systems |
Real-World Use Cases
Use Case 1: Personal Productivity Agent (1 agent)
Scenario: You want one Openclaw agent to manage your personal email, calendar, and tasks.
Recommendation: Gmail
Why: You already have a Gmail account, it integrates seamlessly with Calendar and Drive, and you're only managing one inbox. The $0 cost (free Gmail) or $6/month (if you need Workspace features) is reasonable.
However, if you prefer keeping your agent isolated from your personal Gmail for security reasons (avoiding risk of prompt injection to sensitive personal data), or if you don't need Calendar/Drive integration, AgentMail's free tier (3 inboxes) covers this use case at $0 cost. Setup is simpler (just API key, no OAuth), and you maintain better separation between personal and agent email. You can still connect Google Drive and Google Workspace tools to your AgentMail inbox using MCP tools if needed.
Setup:
# During Openclaw setup, choose Google OAuth
# Grant permissions to Gmail, Calendar, Drive
# Your agent can now read/send emails, schedule meetings, access docs
Use Case 2: Customer Support Automation (5 agents)
Scenario: You're building a customer support system with 5 specialised Openclaw agents (billing, technical, sales, onboarding, escalations).
Recommendation: AgentMail
Why:
- 5 Gmail inboxes = $60/month (Business Standard).
- AgentMail = ~$20/month for 10 inboxes.
- Programmatic inbox creation makes setup easy.
- Webhooks enable real-time ticket routing without dealing with complex PubSub.
Setup:
import { AgentMailClient } from "agentmail";
const client = new AgentMailClient({
environment: "https://api.agentmail.to",
apiKey: process.env.AGENTMAIL_API_KEY
});
// Create 5 specialized inboxes programmatically
const agents = ["billing", "technical", "sales", "onboarding", "escalations"];
for (const agent of agents) {
const inbox = await client.inboxes.create({
username: agent,
displayName: `${agent.charAt(0).toUpperCase() + agent.slice(1)} Agent`
});
console.log(`Created: ${inbox.inboxId}`);
}
Use Case 3: QA Testing with Automated Signups (50+ temporary inboxes)
Scenario: You're testing signup flows for 50 different services, each requiring email verification.
Recommendation: AgentMail
Why:
- Creating 50 Gmail accounts manually is impractical.
- AgentMail lets you delete inboxes on demand.
- OTP extraction is simple to configure.
Setup:
// Create temporary test inbox
const testInbox = await client.inboxes.create({
username: `test-${Date.now()}`
});
// Use for signup
await signUpForService(testInbox.inboxId);
// Wait for verification email via webhook
// Extract OTP code
// Complete verification
// Delete inbox when done
await client.inboxes.delete(testInbox.inboxId);
Use Case 4: Multi-Tenant SaaS (1 inbox per customer)
Scenario: You're building a product where each customer gets their own AI agent with a dedicated email inbox.
Recommendation: AgentMail
Why:
- Gmail would require manual and expensive account creation for each customer
- Programmatic inbox creation is essential.
Setup:
// When new customer signs up
async function onboardCustomer(customerId: string, customerDomain: string) {
const inbox = await client.inboxes.create({
username: customerId,
domain: customerDomain, // Custom domain support
displayName: `AI Assistant for ${customerId}`
});
// Store inboxId in your database
await db.customers.update(customerId, { agentInboxId: inbox.inboxId });
return inbox;
}
Migration Guide: Moving from Gmail to AgentMail
If you start with Gmail and later need to scale to AgentMail, here's how to migrate:
Step 1: Set Up AgentMail
npm install agentmail dotenv
Create .env:
AGENTMAIL_API_KEY=your_api_key_here
Step 2: Create Equivalent Inboxes
import { AgentMailClient } from "agentmail";
const client = new AgentMailClient({
environment: "https://api.agentmail.to",
apiKey: process.env.AGENTMAIL_API_KEY
});
// Create inbox matching your Gmail address
const inbox = await client.inboxes.create({
username: "support-agent", // Was support-agent@gmail.com
displayName: "Support Agent"
});
console.log(`New inbox: ${inbox.inboxId}`); // support-agent@agentmail.to
Step 3: Set Up Email Forwarding
In Gmail settings:
- Go to Settings → Forwarding and POP/IMAP.
- Add forwarding address
- Verify the new forwarding address.
- Select enable forwarding
This way, you will not miss any emails during the transition.
Step 4: Update Your Openclaw Configuration
Replace Gmail logic with AgentMail API key in your Openclaw agent's configuration.
Step 5: Monitor Both Inboxes
Use both Gmail and AgentMail at the same time for one or two weeks to make sure the transition goes smoothly.
Hybrid Approach: Best of Both Worlds
You do not have to pick only one option. Many users use a hybrid setup:
Scenario: Personal + Production Agents
- Personal agent → Gmail (familiar, integrated with Calendar/Drive)
- Production agents (customer support, testing, automation) → AgentMail (scalable, cost-effective)
Example Architecture
Personal Openclaw Agent
├── Gmail (you@gmail.com)
├── Google Calendar
└── Google Drive
Production Openclaw Agents
├── support@agentmail.to (Customer Support)
├── billing@agentmail.to (Billing Inquiries)
├── qa-test-1@agentmail.to (QA Testing)
├── qa-test-2@agentmail.to (QA Testing)
└── ... (scale as needed)
Benefits:
- Keep familiar with Gmail for personal use.
- Scale production agents cost-effectively
- Best tool for each job
Gmail API vs AgentMail API
Gmail API Example (Sending Email)
import { google } from 'googleapis';
// Complex OAuth setup required
const oauth2Client = new google.auth.OAuth2(
CLIENT_ID,
CLIENT_SECRET,
REDIRECT_URI
);
oauth2Client.setCredentials({ refresh_token: REFRESH_TOKEN });
const gmail = google.gmail({ version: 'v1', auth: oauth2Client });
// Encode email in base64
const message = [
'To: recipient@example.com',
'Subject: Hello from Openclaw',
'',
'This is the email body.'
].join('\n');
const encodedMessage = Buffer.from(message)
.toString('base64')
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=+$/, '');
// Send email
await gmail.users.messages.send({
userId: 'me',
requestBody: {
raw: encodedMessage
}
});
Complexity: High (OAuth, base64 encoding, API setup)
AgentMail API Example (Sending Email)
import { AgentMailClient } from "agentmail";
const client = new AgentMailClient({
environment: "https://api.agentmail.to",
apiKey: process.env.AGENTMAIL_API_KEY
});
// Send email
await client.inboxes.messages.send("support-agent@agentmail.to", {
to: ["recipient@example.com"],
subject: "Hello from Openclaw",
text: "This is the email body.",
html: "<p>This is the email body.</p>"
});
Complexity: Low (simple API key, straightforward method)
FAQ
Can I use my own domain with AgentMail?
Yes! AgentMail supports custom domains on paid plans. Instead of agent@agentmail.to, you can use agent@yourdomain.com.
Can I access AgentMail inboxes from my phone?
AgentMail is API-only, so there's no official mobile app. However, you could build a simple mobile interface using the API, or access via webhooks that forward to your personal email.
What if I need more than 2,000 emails/day with Gmail?
You'd need to: (1) Request quota increases from Google (not guaranteed), (2) Use multiple Gmail accounts and distribute the load, or (3) Switch to a dedicated email service like AgentMail.
Is AgentMail secure?
Yes. AgentMail uses TLS and data encryption, API key authentication, and webhook signature verification.
Can I try AgentMail before committing?
Yes! AgentMail offers a free tier with 3 inboxes and limited volume, perfect for testing.
AgentMail gives your agents real inboxes. Create inboxes via API. Send and receive Emails with 0 complexity. Free to start.

