๐Ÿ”—Integration & Channels

How to Connect OpenClaw to Email

Intermediate1-2 hoursUpdated 2025-05-01

Email integration lets OpenClaw monitor an inbox via IMAP and send replies via SMTP, turning any email address into an AI-powered support channel. This intermediate guide walks you through enabling IMAP access, generating app-specific passwords, configuring OpenClaw for email, and setting up filters and auto-reply behavior.

Why This Is Hard to Do Yourself

These are the common pitfalls that trip people up.

๐Ÿ”

App-specific passwords

Most email providers block direct password login for third-party apps. You need an app-specific password or OAuth2 credentials instead.

๐Ÿ“ฌ

IMAP configuration

IMAP settings vary by provider โ€” host, port, TLS mode, and folder names all differ between Gmail, Outlook, and self-hosted mail.

๐Ÿ”„

Polling vs IDLE

IMAP IDLE provides near-instant delivery but not all servers support it. Polling is universal but adds latency.

๐Ÿšซ

Spam and loop prevention

Auto-replying to emails risks creating infinite reply loops with other auto-responders or getting flagged as spam.

Step-by-Step Guide

Step 1

Enable IMAP access

# Gmail: Settings โ†’ See all settings โ†’ Forwarding and POP/IMAP โ†’ Enable IMAP
# Outlook: Settings โ†’ Mail โ†’ Sync email โ†’ POP and IMAP โ†’ Enable IMAP
# Self-hosted: Check your mail server documentation

Warning: Some organizations disable IMAP access via admin policy. Check with your IT admin if you cannot enable it.

Step 2

Generate an app-specific password

# Gmail:
# 1. Go to myaccount.google.com/apppasswords
# 2. Select app: "Other" โ†’ name it "OpenClaw"
# 3. Copy the 16-character password
#
# Outlook / Microsoft 365:
# 1. Go to account.microsoft.com/security
# 2. Select "Advanced security options"
# 3. Under "App passwords", create a new one
# 4. Copy the generated password

Warning: App passwords bypass 2FA. Store them securely โ€” never commit them to version control.

Step 3

Configure OpenClaw for email

# In config/channels/email.yaml:
email:
  enabled: true
  imap:
    host: "imap.gmail.com"      # or imap-mail.outlook.com
    port: 993
    tls: true
    username: "bot@example.com"
    password: "YOUR_APP_PASSWORD"
    folder: "INBOX"             # Folder to monitor
    idle: true                  # Use IMAP IDLE if supported
    poll_interval: 60           # Fallback poll interval in seconds
  smtp:
    host: "smtp.gmail.com"      # or smtp-mail.outlook.com
    port: 587
    tls: starttls               # or "tls" for port 465
    username: "bot@example.com"
    password: "YOUR_APP_PASSWORD"
  from_name: "OpenClaw AI"
  reply_prefix: "[OpenClaw]"    # Subject prefix for replies
Step 4

Set up email filters

# In config/channels/email.yaml (continued):
filters:
  allowed_senders: []          # Empty = all senders, or list addresses
  blocked_senders:
    - "noreply@*"              # Ignore no-reply addresses
    - "mailer-daemon@*"        # Ignore bounce messages
  subject_filters:
    include: []                # Only process matching subjects
    exclude:
      - "Out of Office"        # Skip auto-replies
      - "Undeliverable"        # Skip bounce notices
  max_age_hours: 24            # Ignore emails older than this
Step 5

Configure loop prevention

# In config/channels/email.yaml (continued):
safety:
  max_replies_per_thread: 5    # Stop replying after N messages in a thread
  cooldown_seconds: 30         # Minimum time between replies to same sender
  skip_auto_replies: true      # Ignore emails with Auto-Submitted header
  add_headers:
    X-Auto-Reply: "OpenClaw"   # Mark outgoing emails to prevent loops
    Auto-Submitted: "auto-replied"

Warning: Without loop prevention, two auto-responders can create an infinite reply chain. Always enable skip_auto_replies.

Step 6

Test the integration

# Send a test email to your configured address
# Check OpenClaw logs:
tail -f ~/.openclaw/logs/channels.log | grep email

# Verify IMAP connection:
openclaw channel test email --verbose

Email Integration Has Hidden Complexity

IMAP quirks, provider-specific settings, app passwords, loop prevention, spam avoidance, and thread handling โ€” our integration experts configure email channels that work reliably without creating support headaches.

Get matched with a specialist who can help.

Sign Up for Expert Help โ†’

Frequently Asked Questions