Humans get email addresses by signing up. Fill out a form, verify your phone number, and you're done.
Your Openclaw agent also needs an email address, but the process is different. There are no web forms or manual verification steps. Everything should be set up through code, programmatically, to match an AI Agent's throughput.
This guide shows you how to give your Openclaw agent its own dedicated email address using AgentMail. You'll create an inbox via API, integrate it with Openclaw's skill system, and configure your agent to send and receive emails on its own.
By the end, your Openclaw agent will be able to handle verification emails, reply to customer questions, and manage communication tasks without human intervention.
New to agent email? Read why AI agents need email first.
Why Separate Email Addresses Matter for Openclaw
You wouldn't share your personal Gmail inbox with every employee. The same idea applies to Openclaw agents, but the risk is higher.
An email inbox contains sensitive data like verification codes, password resets, private links, and instructions that can change agent behavior. If multiple agents share an inbox, things bleed together. Agent A can see or act on emails meant for Agent B, and a single malicious or malformed email can trigger the wrong behavior through prompt injection.
Trying to create separate agent accounts with Gmail or Outlook introduces new problems. These providers often block or restrict automated agent accounts, cutting off inbox access and breaking workflows. OAuth limits and per user pricing also make this expensive and brittle as you scale.
AgentMail is purpose built for this use case. You can create isolated inboxes with code, send and receive emails safely, avoid account bans and OAuth limits, and pay based on usage instead of per seat.
AgentMail gives your agents real inboxes. Create inboxes via API. Send and receive Emails with 0 complexity. Free to start.
What You'll Build
This tutorial covers:
- Creating a dedicated email inbox via API
- Installing the AgentMail skill in Openclaw
- Configuring your agent to send emails
- Setting up real-time webhook notifications
- Testing the complete workflow
What you need:
- Openclaw installed and running (see Openclaw documentation)
- AgentMail API key (free tier includes 3 inboxes)
- Basic familiarity with the command line
Time to complete: 15-20 minutes
Step 1: Create Your Openclaw Agent's Inbox
First, get your AgentMail API key from the AgentMail Console.
Install the AgentMail TypeScript SDK:
npm install agentmail
Create an inbox for your Openclaw agent:
import { AgentMailClient } from 'agentmail'
async function main() {
const client = new AgentMailClient({
environment: 'https://api.agentmail.to',
apiKey: 'YOUR_TOKEN_HERE',
})
await client.inboxes.create({
displayName: 'Openclaw Support Inbox',
clientId: '1c6e9f4a-8b2d-4f3a-9d7e-2a1b3c4d5e6f',
})
}
main()
Response:
{
"pod_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"inbox_id": "support-agent@agentmail.to",
"updated_at": "2026-01-29T12:00:00Z",
"display_name": "Openclaw Support Inbox",
"created_at": "2026-01-29T12:00:00Z",
"client_id": "1c6e9f4a-8b2d-4f3a-9d7e-2a1b3c4d5e6f"
}
Your Openclaw agent now has an email address: support-agent@agentmail.to. The inbox_id is the full email address. The inbox is ready to send and receive immediately.
Custom Domain (Optional)
Want support@yourdomain.com instead of @agentmail.to? Add a custom domain (available at any paid plan):
// Create a custom domain
import { AgentMailClient } from 'agentmail'
async function main() {
const client = new AgentMailClient({
environment: 'https://api.agentmail.to',
apiKey: 'YOUR_TOKEN_HERE',
})
await client.domains.create({
domain: 'yourdomain.com',
feedbackEnabled: true, // Enable bounce or complaint notifications
})
}
main()
Response:
{
"domain_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"status": "NOT_STARTED",
"feedback_enabled": true,
"records": [
{
"type": "TXT",
"name": "_dmarc.yourdomain.com",
"value": "v=DMARC1; p=none; rua=mailto:dmarc-feedback@example.com",
"status": "MISSING",
"priority": 1
},
{
"type": "TXT",
"name": "example.com",
"value": "v=spf1 include:_spf.yourdomain.com ~all",
"status": "MISSING",
"priority": 1
}
],
"updated_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z",
"pod_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"client_id": "9b2d6f4e-8c3a-4f1a-9d2e-1a2b3c4d5e6f"
}
AgentMail provides DNS records to add. Once verified, create inboxes on your domain:
import { AgentMailClient } from 'agentmail'
const client = new AgentMailClient({
environment: 'https://api.agentmail.to',
apiKey: process.env.AGENTMAIL_API_KEY,
})
const customInbox = await client.inboxes.create({
username: 'support',
domain: 'yourdomain.com',
displayName: 'Support Agent',
})
// inbox_id will be: support@yourdomain.com
console.log(customInbox.inbox_id)
Now your Openclaw agent sends from support@yourdomain.com. Professional appearance, your brand.
Step 2: Install the AgentMail Skill in Openclaw
Openclaw uses skills to extend agent capabilities. The AgentMail skill gives your Openclaw agent email functions: send, receive, reply, and forward.
Installation
Install via Openclaw CLI:
openclaw skills install agentmail-to/agentmail-skills/agentmail
Or install via ClawdHub:
clawdhub install agentmail
Configuration
Add your API key to Openclaw's configuration file at ~/.openclaw/openclaw.json:
{
"skills": {
"entries": {
"agentmail": {
"enabled": true,
"env": {
"AGENTMAIL_API_KEY": "your-api-key-here"
}
}
}
}
}
Verify Installation
Check that the skill is loaded:
openclaw skills list --eligible
You should see Agentmail listed among the available skills.
Step 3: Send Your First Email with Openclaw
Test the Openclaw email integration by sending an email through the SDK.
Command:
"Send an email to customer@example.com with subject 'Test Email' and body 'This is a test from my Openclaw agent.'"
Openclaw executes:
await client.inboxes.messages.send({
inbox_id: 'support-agent@agentmail.to',
to: ['customer@example.com'],
subject: 'Test Email',
text: 'This is a test from my Openclaw agent.',
})
The email is sent from your Openclaw agent's inbox. The recipient will see it coming from support-agent@agentmail.to (or your custom domain)
Sending with HTML
For better formatting and deliverability, always include both HTML and text versions:
{
"to": ["customer@example.com"],
"subject": "Order Confirmation",
"text": "Your order has shipped. Tracking: ABC123",
"html": "<p>Your order has shipped.</p><p><strong>Tracking:</strong> ABC123</p>"
}
Emails with only HTML content can get flagged as spam by email providers. Including both versions significantly improves deliverability. Email clients display the HTML version when available, with the text version as fallback for compatibility.
Step 4: Receive and Parse Incoming Emails in Openclaw
Sending emails is only part of the process. Your Openclaw agent also needs to receive replies.
Set Up Webhooks
Webhooks send email data to your application as soon as a message arrives. There's no need to poll or wait.
Configure a webhook endpoint:
// Create a webhook for real-time notifications
const webhook = await client.webhooks.create({
url: 'https://your-openclaw-webhook-url',
event_types: ['message.received'],
})
console.log(webhook.webhook_id)
console.log(webhook.secret) // Use this to verify webhook signatures
When an email arrives, AgentMail sends this payload to your endpoint. Your Openclaw agent will process this information and decide what to do next.
Example: Auto-Reply Workflow
Configure Openclaw to reply automatically using the SDK:
// Webhook handler function
async function handleIncomingEmail(payload: any) {
const message = payload.message
const inboxId = payload.inbox_id
// Extract order number from subject
const orderId = extractOrderId(message.subject)
// Look up order status
const status = await getOrderStatus(orderId)
// Reply with status
await client.inboxes.messages.reply({
inbox_id: inboxId,
message_id: message.message_id,
text: `Your order ${orderId} is currently ${status}. Expected delivery: 2 business days.`,
})
}
The agent receives an email, reads the content, finds the needed information, and replies on its own.
Step 5: Handle Verification Emails and OTP Codes with Openclaw
One of the most powerful use cases: Openclaw agents that automatically sign up for services.
Many internet services require email verification. Your Openclaw agent receives the verification email, extracts the OTP code or clicks the confirmation link, and completes signup without human intervention.
OTP Extraction
AgentMail includes built-in 2FA code extraction:
// Get message details
const message = await client.inboxes.messages.get({
inbox_id: 'support-agent@agentmail.to',
message_id: 'msg_xyz789',
})
// Access message content
console.log(message.text) // "Your verification code is 123456"
// Parse OTP from message body
const otpMatch = message.text.match(/\b\d{6}\b/)
const otpCode = otpMatch ? otpMatch[0] : null
console.log(otpCode) // "123456"
Your Openclaw agent extracts the OTP code and completes the verification flow automatically.
Confirmation Links
For services that send confirmation links instead of codes, parse the email body for URLs:
// Extract verification links from email
const urlMatch = message.text.match(/https?:\/\/[^\s]+/)
const verificationLink = urlMatch ? urlMatch[0] : null
if (verificationLink) {
// Openclaw agent navigates to verification link
console.log(`Verification link: ${verificationLink}`)
}
The Openclaw agent navigates to the verification link and completes signup.
Step 6: Multi-Threaded Conversations with Openclaw
Email isn't limited to one-on-one messages. Your Openclaw agent can be CC'd on group threads, added to ongoing conversations, and talk with several people at once.
This is one of the main strengths of using email with Openclaw agents.
Replying in Threads
AgentMail handles email threading automatically. When your Openclaw agent replies, the response appears in the correct conversation thread:
// Reply to a specific message
const reply = await client.inboxes.messages.reply('support-agent@agentmail.to', 'msg_xyz789', {
text: 'Thanks for confirming. We will process your request.',
attachments: [
{
content: 'resume',
},
],
})
console.log(`Reply sent successfully with ID: ${reply.id}`)
The reply includes the right Message-ID, In-Reply-To, and References headers, so email clients automatically group the messages into a thread.
CC and Forward Your Openclaw Agent
Your Openclaw agent can be CC'd on team emails:
Human email:
To: john@company.com
CC: support-agent@agentmail.to
Subject: Project Update
Can you update the timeline?
Your Openclaw agent receives the email, parses the request, and responds to the thread:
To: john@company.com
Subject: Re: Project Update
Updated timeline: Phase 1 complete by Feb 15. Phase 2 complete by Mar 1.
The Openclaw agent joins the conversation just like any other team member. All context is kept, and no information is lost.
Step 7: Manage Multiple Openclaw Agent Inboxes
Most production systems run multiple Openclaw agents. Customer support, sales, QA testing, and signup automation. Each needs its own inbox.
Create Inboxes on Demand
Spin up an inbox when a workflow starts:
import { AgentMailClient } from 'agentmail'
const client = new AgentMailClient({
environment: 'https://api.agentmail.to',
apiKey: process.env.AGENTMAIL_API_KEY,
})
// Create inbox for new customer dynamically
const customerInbox = await client.inboxes.create({
username: 'customer-12345-support',
displayName: 'Support Agent for Customer 12345',
})
console.log(customerInbox.inbox_id) // customer-12345-support@agentmail.to
Each customer's Openclaw agent has its own inbox. This keeps messages separate and avoids any mix-ups.
List All Openclaw Agent Inboxes
View all Openclaw agent inboxes:
// List all inboxes (assumes client from previous example)
import { AgentMailClient } from 'agentmail'
async function main() {
const client = new AgentMailClient({
environment: 'https://api.agentmail.to',
apiKey: 'YOUR_TOKEN_HERE',
})
await client.inboxes.list({})
}
main()
Response:
{
"count": 2,
"inboxes": [
{
"pod_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"inbox_id": "support-agent@agentmail.to",
"updated_at": "2026-01-15T09:30:00Z",
"created_at": "2026-01-10T08:15:00Z",
"display_name": "Openclaw Support Inbox",
"client_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7"
},
{
"pod_id": "1c6b147e-8f3a-4d2a-9f3e-1a2b3c4d5e6f",
"inbox_id": "customer-12345-support@agentmail.to",
"updated_at": "2026-01-15T09:30:00Z",
"created_at": "2026-01-12T11:45:00Z",
"display_name": "Support Agent for Customer 12345",
"client_id": "2f1e4d6a-3b7c-4d8e-9f0a-1b2c3d4e5f6a"
}
],
"limit": 2,
"next_page_token": "eyJwYWdlIjoxfQ=="
}
Delete Inboxes
When a workflow completes, delete the inbox:
import { AgentMailClient } from 'agentmail'
async function main() {
const client = new AgentMailClient({
environment: 'https://api.agentmail.to',
apiKey: 'YOUR_TOKEN_HERE',
})
await client.inboxes.delete('inbox_id')
}
main()
You can create inboxes when you need them and delete them when you're finished.
Understanding Email Deliverability for Openclaw
It's important that your Openclaw agent's emails go to inboxes, not spam folders.
Three protocols matter: SPF, DKIM, and DMARC.
SPF (Sender Policy Framework): A DNS record listing which servers can send on your domain's behalf. Receiving servers check if the sending IP is authorized. Prevents spoofing.
DKIM (DomainKeys Identified Mail): A cryptographic signature proving the message wasn't altered in transit. The private key signs outgoing mail. The public key in DNS verifies it. Ensures integrity.
DMARC (Domain-based Message Authentication, Reporting, and Conformance): Policy telling receivers what to do when SPF or DKIM fail. Report, quarantine, or reject. Provides visibility.
When you add a custom domain to AgentMail, all three are configured automatically. You add DNS records during setup. Deliverability is handled from there.
No manual debugging. No IP reputation management. Just working on email.
Real-World Openclaw Email Use Cases
Here's how production systems use Openclaw email integration:
1. Customer Support Automation
Setup: support@yourdomain.com inbox receives customer inquiries.
Workflow:
- Customer emails support
- Webhook fires, Openclaw agent receives message.
- Openclaw agent analyzes the inquiry and checks the knowledge base.
- Openclaw agent replies with a solution or escalates to a human.
- Thread maintained across multiple exchanges, forwards to different teams if needed
As a result, about 70% of support tickets are handled automatically, so your team can focus on more complex issues.
2. QA Testing Signup Flows
Setup: Multiple test inboxes (qa-test-1@agentmail.to, qa-test-2@agentmail.to)
Workflow:
- Openclaw agent navigates to the signup page.
- Openclaw agent enters test email address.
- Verification email arrives, Openclaw agent extracts OTP.
- Openclaw agent completes signup and validates account
- Process repeats for each test case.
This means you get automated end-to-end testing without manual verification.
3. Onboarding Automation
Setup: onboarding@yourdomain.com sends welcome sequences.
Workflow:
- New user signs up
- Openclaw agent sends a welcome email immediately.
- Openclaw agent sends tutorial email after 24 hours.
- Openclaw agent sends a check-in email after 7 days.
- Openclaw agent adjusts the sequence based on user activity.
You get personalized onboarding at scale, without needing a separate marketing automation platform.
4. System Monitoring Alerts
Setup: alerts@yourdomain.com receives system notifications.
Workflow:
- Server health check fails.
- Monitoring system emails alert inbox
- Openclaw agent receives a webhook and parses the alert.
- Openclaw agent attempts automated fix.
- Openclaw agent escalates to an on-call engineer if the fix fails.
This leads to proactive issue resolution and faster response times.
Troubleshooting Common Issues
Issue: Skill Not Loading
Symptom: Openclaw doesn't recognize email commands.
Fix:
- Verify skill is installed:
openclaw skills list --eligible - Check configuration file at
~/.openclaw/openclaw.json - Ensure the API key is correct.
- Restart Openclaw:
openclaw restart
Issue: Emails Landing in Spam
Symptom: Sent emails go to the recipient's spam folder.
Fix:
- If using a custom domain, verify DNS records are correct.
- Check SPF, DKIM, and DMARC records via MXToolbox
- Warm up your domain by gradually increasing your volume.
- Avoid spam trigger words in subject lines or email body.
Issue: Webhooks Not Firing
Symptom: The Openclaw agent doesn't receive notifications for incoming emails.
Fix:
- Verify the webhook URL is publicly accessible.
- Check webhook configuration:
curl https://api.agentmail.to/v0/webhooks -H "Authorization: Bearer YOUR_API_KEY" - Review webhook logs in AgentMail Console.
- Ensure endpoint returns 200 status code.
Next Steps
Your Openclaw agent now has a working email address. It can send, receive, reply to emails, and handle verification tasks on its own.
Here's what to explore next:
Level up your Openclaw agent:
- Read: Why AI Agents Need Email to understand how inboxes serve as long-term context.
- Read: Email Deliverability 101 to explore authentication and trust.
Production deployments:
- Add monitoring for email delivery rates.
- Set up fallback webhooks for reliability.
- Implement retry logic for failed sends.
- Configure alerts for inbox quota limits
Advanced Openclaw patterns:
- Multi-agent coordination via CC and forward
- Semantic search across Openclaw agent email history
- Automated inbox management and cleanup
- Dynamic routing based on email content
AgentMail gives your agents real inboxes. Create inboxes via API. Send and receive Emails with 0 complexity. Free to start.
FAQ
Can I use Gmail instead of AgentMail?
Technically, yes, but Gmail wasn't built for agents. OAuth complexity for programmatic access. Rate limits that break at scale. You also run the risk of Gmail banning your account. $6-14 per inbox per month minimum. At 50 agents, you're paying $3,600-8,400 annually. Gmail works for one or two agents. Doesn't scale beyond that.
How fast do webhooks deliver emails?
Typically, 1-5 seconds from when the message arrives at the mail server. WebSockets can be faster for use cases requiring sub-second latency. Webhook delivery depends on your endpoint's response time.
What happens if my webhook endpoint is down?
AgentMail retries failed webhooks with exponential backoff (up to 24 hours). You can also poll the messages endpoint manually to retrieve missed emails. Configure multiple webhook endpoints for redundancy.
Can Openclaw agents maintain conversation threads across multiple replies?
Yes. AgentMail automatically handles Message-ID, In-Reply-To, and References headers. When your Openclaw agent calls the reply endpoint, the response appears in the correct thread. No manual header management required.
How many inboxes can I create?
No hard limit on inbox creation. Free tier includes 3 inboxes. Paid plans scale based on usage. Enterprise customers run thousands of agent inboxes without issues.
Do I need to manage SPF, DKIM, and DMARC myself?
Not with AgentMail. When you verify a custom domain, all authentication records are configured automatically. You add DNS records during initial setup. Deliverability is handled from there.

