Skip to content
Blog / Developer Resources

Give Your OpenClaw Agent Its Own Email Inbox, Without Gmail

Binoy Perera

Updated

Create a dedicated inbox for your OpenClaw agent: programmatic setup, OTP and verification handling, threading and webhooks. No Google account, no OAuth consent screen.

  • openclaw
  • ai agents
  • email integration
  • agentmail
  • programmatic inboxes
  • webhook notifications
  • OTP verification
  • agent email
  • openclaw skills
  • email automation
  • openclaw gmail
  • openclaw email
  • openclaw gmail integration
  • openclaw outlook
  • openclaw email integration
  • openclaw agent
  • openclaw webhook
  • openclaw outlook integration
  • openclaw mail
  • agentmail openclaw
  • openclaw send email
  • openclaw gmail skill
  • openclaw email skill
  • openclaw webhooks
  • openclaw agentmail
  • openclaw imap

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.

What You'll Build

This tutorial covers:

  1. Creating a dedicated email inbox via API
  2. Installing the AgentMail skill in OpenClaw
  3. Configuring your agent to send emails
  4. Setting up real-time webhook notifications
  5. 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:

Bash

npm install agentmail

Create an inbox for your OpenClaw agent:

TypeScript

import { AgentMailClient } from "agentmail";async function main() {    const client = new AgentMailClient({        apiKey: "YOUR_TOKEN_HERE",    });    await client.inboxes.create({        username: "support-agent-openclaw",        displayName: "OpenClaw Support Inbox",    });}main();

Response:

JSON

{  "organization_id": "25182507-301a-4c93-a29e-86e53e5b2a22",  "podId": "25182507-301a-4c93-a29e-86e53e5b2a22",  "inboxId": "support-agent-openclaw@agentmail.to",  "email": "support-agent-openclaw@agentmail.to",  "displayName": "OpenClaw Support Inbox",  "updatedAt": "2026-03-31T20:02:34.784Z",  "createdAt": "2026-03-31T20:02:34.784Z"}

Your OpenClaw agent now has an email address: support-agent-openclaw@agentmail.to. The inboxId 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):

TypeScript

// Create a custom domainimport { AgentMailClient } from "agentmail";async function main() {    const client = new AgentMailClient({        apiKey: "YOUR_TOKEN_HERE",    });    await client.domains.create({        domain: "YOUR_DOMAIN_HERE",        feedbackEnabled: true,    });}main();

Response:

JSON

{    "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        }    ],    "updatedAt": "2024-01-15T09:30:00Z",    "createdAt": "2024-01-15T09:30:00Z",    "podId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",    "clientId": "9b2d6f4e-8c3a-4f1a-9d2e-1a2b3c4d5e6f"}

AgentMail provides DNS records to add. Once verified, create inboxes on your domain:

TypeScript

import { AgentMailClient } from 'agentmail'const client = new AgentMailClient({    apiKey: process.env.AGENTMAIL_API_KEY,})const customInbox = await client.inboxes.create({    username: 'support',    domain: 'yourdomain.com',    displayName: 'Support Agent',})// inboxId will be: support@yourdomain.comconsole.log(customInbox.inboxId)

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. You can use the official skill (recommended) or create a custom skill.

The easiest way to add email capabilities to OpenClaw is by installing the official AgentMail skill from skills.sh. This skill is maintained by the AgentMail team and provides comprehensive email functionality.

Installation

Install the skill via ClawHub:

Bash

npx clawhub@latest install agentmail

Or, if you have ClawHub installed globally:

Bash

clawhub install agentmail

Configuration

Add your AgentMail API key to the skill configuration in ~/.openclaw/openclaw.json:

JSON

{  "skills": {    "entries": {      "agentmail": {        "enabled": true,        "env": {          "AGENTMAIL_API_KEY": "your-api-key-here"        }      }    }  }}

Get your API key from the AgentMail Console.

Features

The official skill includes:

  • Inbox management: Create scalable inboxes on-demand with unique email addresses
  • Message operations: Send emails with text and HTML content for best deliverability
  • Thread management: Group related messages in conversations
  • Attachments: Send and receive attachments with Base64 encoding
  • Drafts: Create drafts for human-in-the-loop approval before sending
  • Pods: Multi-tenant isolation for SaaS platforms
  • Idempotency: Safe retries on create operations
  • Real-time events: WebSocket and webhook support for notifications

Verify installation

Check that the skill is loaded:

Bash

openclaw skills list --eligible

You should see agentmail in the list of available skills.

Option 2: Custom Skill

For more control over the integration, you can create a custom AgentMail skill. Skills are directories containing a SKILL.md file with instructions for OpenClaw.

Create the skill directory

Create a new skill in your OpenClaw workspace:

Bash

mkdir -p ~/.openclaw/skills/agentmail

Create the skill file

Create ~/.openclaw/skills/agentmail/SKILL.md with the following content:

Code

---name: agentmaildescription: Send and receive emails using AgentMailrequires:  env:    - AGENTMAIL_API_KEY---# AgentMail SkillYou can send and receive emails using the AgentMail API. Use the `exec` tool to run curl commands against the AgentMail API.## API Base URLhttps://api.agentmail.to/v0## AuthenticationInclude your API key in the Authorization header:Authorization: Bearer $AGENTMAIL_API_KEY## Common Operations### List inboxescurl -s -H "Authorization: Bearer $AGENTMAIL_API_KEY" \  https://api.agentmail.to/v0/inboxes### Create an inboxcurl -s -X POST -H "Authorization: Bearer $AGENTMAIL_API_KEY" \  -H "Content-Type: application/json" \  -d '{"display_name": "My Agent"}' \  https://api.agentmail.to/v0/inboxes### Send an emailcurl -s -X POST -H "Authorization: Bearer $AGENTMAIL_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "to": ["recipient@example.com"],    "subject": "Hello from OpenClaw",    "text": "This email was sent by my AI assistant."  }' \  https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/send### List messages in an inboxcurl -s -H "Authorization: Bearer $AGENTMAIL_API_KEY" \  https://api.agentmail.to/v0/inboxes/{inbox_id}/messages### Reply to a messagecurl -s -X POST -H "Authorization: Bearer $AGENTMAIL_API_KEY" \  -H "Content-Type: application/json" \  -d '{"text": "Thanks for your email!"}' \  https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/{message_id}/reply

Configure the skill

Add your AgentMail API key to the skill configuration in ~/.openclaw/openclaw.json:

JSON

{  "skills": {    "entries": {      "agentmail": {        "enabled": true,        "env": {          "AGENTMAIL_API_KEY": "your-api-key-here"        }      }    }  }}

Verify the skill

Check that the skill is loaded:

Bash

openclaw skills list --eligible

You should see agentmail in the list of 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:

TypeScript

 await client.inboxes.messages.send("support-agent-openclaw@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-openclaw@agentmail.to (or your custom domain)

Sending with HTML

For better formatting and deliverability, always include both HTML and text versions:

JSON

{    "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:

TypeScript

// Create a webhook for real-time notificationsconst webhook = await client.webhooks.create({    url: "https://your-openclaw-webhook-url",    eventTypes: [        "message.received",        "message.sent",    ],})console.log(webhook.webhookId)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:

TypeScript

// Webhook handler functionasync function handleIncomingEmail(payload: any) {    const message = payload.message    // Extract order number from subject    const orderId = extractOrderId(message.subject)    // Look up order status    const status = await getOrderStatus(orderId)    // Reply with status (inbox_id is on the message object in webhook payloads)    await client.inboxes.messages.reply(message.inboxId , message.messageId, {        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:

TypeScript

// Get message detailsconst message = await client.inboxes.messages.get("support-agent-openclaw@agentmail.to", "msg_xyz789")// Access message contentconsole.log(message.text) // "Your verification code is 123456"// Parse OTP from message bodyconst otpMatch = message.text?.match(/\b\d{6}\b/)const otpCode = otpMatch ? otpMatch[0] : nullconsole.log(otpCode) // "123456"

Your OpenClaw agent extracts the OTP code and completes the verification flow automatically.

For services that send confirmation links instead of codes, parse the email body for URLs:

TypeScript

// Extract verification links from emailconst urlMatch = message.text?.match(/https?:\/\/[^\s]+/)const verificationLink = urlMatch ? urlMatch[0] : nullif (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:

TypeScript

// Reply to a specific messageconst reply = await client.inboxes.messages.reply("support-agent-openclaw@agentmail.to", "msg_xyz789", {    text: "Thanks for confirming. We will process your request.",});console.log(`Reply sent successfully with ID: ${reply.messageId}`)

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:

Code

To: john@company.comCC: support-agent-openclaw@agentmail.toSubject: Project UpdateCan you update the timeline?

Your OpenClaw agent receives the email, parses the request, and responds to the thread:

Code

To: john@company.comSubject: Re: Project UpdateUpdated 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:

TypeScript

import { AgentMailClient } from 'agentmail'const client = new AgentMailClient({    apiKey: process.env.AGENTMAIL_API_KEY,})// Create inbox for new customer dynamicallyconst customerInbox = await client.inboxes.create({    username: "customer-12345-support-openclaw",    displayName: "Support Agent for Customer 12345",  });console.log(customerInbox.inboxId) // customer-12345-support-openclaw@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:

TypeScript

// List all inboxes (assumes client from previous example)import { AgentMailClient } from 'agentmail'async function main() {    const client = new AgentMailClient({        apiKey: 'YOUR_TOKEN_HERE',    })    await client.inboxes.list({});}main();

Response:

JSON

{    "count": 2,    "inboxes": [        {            "podId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",            "inboxId": "support-agent-openclaw@agentmail.to",            "updatedAt": "2026-01-15T09:30:00Z",            "createdAt": "2026-01-10T08:15:00Z",            "displayName": "OpenClaw Support Inbox",            "clientId": "7c9e6679-7425-40de-944b-e07fc1f90ae7"        },        {            "podId": "1c6b147e-8f3a-4d2a-9f3e-1a2b3c4d5e6f",            "inboxId": "customer-12345-support-openclaw@agentmail.to",            "updatedAt": "2026-01-15T09:30:00Z",            "createdAt": "2026-01-12T11:45:00Z",            "displayName": "Support Agent for Customer 12345",            "clientId": "2f1e4d6a-3b7c-4d8e-9f0a-1b2c3d4e5f6a"        }    ]}

Delete Inboxes

When a workflow completes, delete the inbox:

TypeScript

import { AgentMailClient } from 'agentmail'async function main() {    const client = new AgentMailClient({        apiKey: 'YOUR_TOKEN_HERE',    });    await client.inboxes.delete("support-agent-openclaw@agentmail.to");}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:

  1. Customer emails support
  2. Webhook fires, OpenClaw agent receives message.
  3. OpenClaw agent analyzes the inquiry and checks the knowledge base.
  4. OpenClaw agent replies with a solution or escalates to a human.
  5. 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:

  1. OpenClaw agent navigates to the signup page.
  2. OpenClaw agent enters test email address.
  3. Verification email arrives, OpenClaw agent extracts OTP.
  4. OpenClaw agent completes signup and validates account
  5. 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:

  1. New user signs up
  2. OpenClaw agent sends a welcome email immediately.
  3. OpenClaw agent sends tutorial email after 24 hours.
  4. OpenClaw agent sends a check-in email after 7 days.
  5. 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:

  1. Server health check fails.
  2. Monitoring system emails alert inbox
  3. OpenClaw agent receives a webhook and parses the alert.
  4. OpenClaw agent attempts automated fix.
  5. 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:

  1. Verify skill is installed: openclaw skills list --eligible
  2. Check configuration file at ~/.openclaw/openclaw.json
  3. Ensure the API key is correct.
  4. Restart OpenClaw: openclaw restart

Issue: Emails Landing in Spam

Symptom: Sent emails go to the recipient's spam folder.

Fix:

  1. If using a custom domain, verify DNS records are correct.
  2. Check SPF, DKIM, and DMARC records via MXToolbox
  3. Warm up your domain by gradually increasing your volume.
  4. 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:

  1. Verify the webhook URL is publicly accessible.
  2. Check webhook configuration: curl https://api.agentmail.to/v0/webhooks -H "Authorization: Bearer YOUR_API_KEY"
  3. Review webhook logs in AgentMail Console.
  4. 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:

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

FAQ

Questions, answered.

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.

The Free plan includes 3 inboxes, Developer includes 10, and Startup includes 150. Contact us for a custom Enterprise limit.

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.

Create an account at AgentMail, get an API key, and use the AgentMail SDK to create an inbox programmatically. The inbox is ready to send and receive emails immediately after creation.

Shared inboxes expose sensitive data like verification codes and private links to the wrong agents, and providers like Gmail often block or restrict automated accounts. AgentMail creates isolated inboxes via API, avoiding account bans, OAuth limits, and per-seat pricing.

Yes, custom domains are available on any paid AgentMail plan. After verifying your domain, you can create inboxes like support@yourdomain.com for a professional appearance.

The agent retrieves the incoming message, parses the body for a six-digit code or confirmation URL, and completes the verification flow automatically without human intervention.

AgentMail is now an official OpenClaw plugin on ClawHub, which is the recommended path: openclaw plugins install clawhub:@agentmail/agentmail, then openclaw plugins enable agentmail. Set AGENTMAIL_API_KEY in the Gateway environment and restart with openclaw gateway restart. The older skill-only install still works but does not include the email channel.

Yes. You can CC your agent's inbox on any email, and it will receive the message, parse the request, and reply within the same thread just like any other participant.

Yes. The official AgentMail plugin registers email as an OpenClaw channel. A message sent to the agent's inbox drives an agent turn and the reply lands in the same thread, the way the WhatsApp and Discord channels work. Configure it under channels.agentmail with an inboxId and an allowFrom list of senders you trust.

Attach a domain to your AgentMail organization or pod, then create inboxes on it. The agent addresses them through the same CLI-backed skill, which covers domains alongside inboxes, messages, threads and drafts.

Blog

Suggested reading

View all posts

Developer Resources · January 17, 2026

Why AI Agents Need Email

Why do AI agents need email? From authentication to two-way communication, email infrastructure enables agents to function as first-class internet citizens.

Developer Resources · January 15, 2026

Email Deliverability 101

A high-level, engineering-first guide to why emails land in the inbox (or don't).

Prompt

Give yourself access to AgentMail by following the guide at:

https://docs.agentmail.to/agent-onboarding.md

and refer to:

https://docs.agentmail.to/llms.txt

for the documentation index.

Start integrating AgentMail into your AI agents today.