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.
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.
Three steps to go live
Configure Gmail credentials
Enable IMAP in Gmail settings and create an App Password if 2FA is on.
Go to Gmail Settings > See all settings > Forwarding and POP/IMAP and enable IMAP access
Visit myaccount.google.com/apppasswords - create an App Password for "Mail" and save it securely
Store your credentials as env vars: GMAIL_USER and GMAIL_APP_PASSWORD
[email protected]
GMAIL_APP_PASSWORD=xxxx-xxxx-xxxx-xxxx
# Optional: SMTP config (defaults to Gmail)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587 Create your Gmail pipeline
Build a YAML pipeline that reads or sends email using your stored credentials.
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 expanso-cli pipeline push gmail-reader.yaml to deploy to your Expanso instance. 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 Connect to OpenClaw
Register the Gmail skill in your Claude Desktop config and start using natural language to manage email.
{
"mcpServers": {
"openclaw": {
"command": "openclaw",
"args": ["serve"],
"env": {
"EXPANSO_TOKEN": "your-token-here",
"GMAIL_PIPELINE": "gmail-reader"
}
}
}
} Use cases
Summarize and prioritize unread emails by category, sender, or urgency on demand.
Generate contextual draft replies and send them with a single confirmation command.
Get concise summaries of long email threads without reading every message.
Route emails to folders, apply labels, or forward to teammates based on content rules.
Extract key insights from newsletters and compile them into a single daily summary.
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.