Gmail Integration
IMAP / SMTP / Pub/Sub

Connect Gmail
to Your Pipeline

Read, send, and process email with OpenClaw's Gmail integration. Works with both IMAP/SMTP credentials and Google's Pub/Sub API for real-time streaming.

Prerequisites
OpenClaw installed and connected to Expanso · Gmail account with IMAP enabled · Node.js 18+
How it works
You
AI Assistant
OpenClaw
MCP Agent
Expanso
Your Infra
Gmail
IMAP / Pub/Sub

Your natural language commands flow through OpenClaw to your Expanso-managed pipeline, which reads and sends email via Gmail's APIs. Credentials stay in your infrastructure.

Setup Guide

Three steps to go live

1

Configure Gmail credentials

IMAP / SMTP

Enable IMAP in Gmail settings and create an App Password if 2FA is on.

a

Go to Gmail Settings > See all settings > Forwarding and POP/IMAP and enable IMAP access

b

Visit myaccount.google.com/apppasswords - create an App Password for "Mail" and save it securely

c

Store your credentials as env vars: GMAIL_USER and GMAIL_APP_PASSWORD

.env
[email protected]
GMAIL_APP_PASSWORD=xxxx-xxxx-xxxx-xxxx

# Optional: SMTP config (defaults to Gmail)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
2

Create your Gmail pipeline

Build a YAML pipeline that reads or sends email using your stored credentials.

gmail-reader.yaml
Pipeline:
  Name: gmail-reader
  Description: Read unread emails from Gmail

  InputSources:
    - Type: gmail
      Config:
        host: imap.gmail.com
        port: 993
        username: env:GMAIL_USER
        password: env:GMAIL_APP_PASSWORD
        folder: INBOX
        filter: UNSEEN

  OutputSinks:
    - Type: stdout
Use expanso-cli pipeline push gmail-reader.yaml to deploy to your Expanso instance.
gmail-send.yaml
Pipeline:
  Name: gmail-send
  Description: Send email via Gmail SMTP

  InputSources:
    - Type: http
      Config:
        path: /gmail-send

  Processors:
    - Type: send-email
      Config:
        host: smtp.gmail.com
        port: 587
        username: env:GMAIL_USER
        password: env:GMAIL_APP_PASSWORD

  OutputSinks:
    - Type: sync-response
3

Connect to OpenClaw

Live in 30 seconds

Register the Gmail skill in your Claude Desktop config and start using natural language to manage email.

claude_desktop_config.json
{
  "mcpServers": {
    "openclaw": {
      "command": "openclaw",
      "args": ["serve"],
      "env": {
        "EXPANSO_TOKEN": "your-token-here",
        "GMAIL_PIPELINE": "gmail-reader"
      }
    }
  }
}
You're all set!
Try: "Check my inbox for unread emails from this week"
What you can build

Use cases

01
Email triage

Summarize and prioritize unread emails by category, sender, or urgency on demand.

IMAP / read
02
Draft replies

Generate contextual draft replies and send them with a single confirmation command.

SMTP / send
03
Thread summaries

Get concise summaries of long email threads without reading every message.

IMAP / threads
04
Filter automation

Route emails to folders, apply labels, or forward to teammates based on content rules.

IMAP / labels
05
Newsletter digest

Extract key insights from newsletters and compile them into a single daily summary.

Pub/Sub / stream
FAQ

Common questions

Do my Gmail credentials leave my server?

No. Credentials are stored in environment variables on your Expanso instance. The MCP protocol only passes pipeline commands - never raw credentials or email content.

Does OpenClaw store my emails?

No. OpenClaw reads emails on-demand through Expanso pipelines. Email content is processed in memory during the active request and is not persisted anywhere.

Can OpenClaw send emails without my approval?

That depends on your configuration. By default, OpenClaw drafts replies and presents them for approval before sending. You can configure automated sending for specific workflows, but safety boundaries are always under your control.

Can I connect multiple Gmail accounts?

Yes. Create one pipeline per account with different env var names (e.g. GMAIL_WORK, GMAIL_PERSONAL). Reference the relevant pipeline in your command to target the right inbox.

Does it work with Google Workspace accounts?

Yes, but Workspace admins must enable IMAP for the domain in Google Admin Console. App Passwords require 2-Step Verification to be enabled per user.

Ready to connect Gmail?

Takes about 5 minutes. No extra infrastructure required.