惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
D
Docker
月光博客
月光博客
MongoDB | Blog
MongoDB | Blog
Vercel News
Vercel News
美团技术团队
博客园 - 叶小钗
I
InfoQ
Jina AI
Jina AI
博客园 - 司徒正美
雷峰网
雷峰网
B
Blog
Y
Y Combinator Blog
A
About on SuperTechFans
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Announcements
Recent Announcements
V
V2EX
N
Netflix TechBlog - Medium

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Building an Apple Mail Channel Plugin for OpenClaw
Jehadur Rahman (Emran) · 2026-06-22 · via DEV Community

Jehadur Rahman (Emran)

Building an Apple Mail Channel Plugin for OpenClaw

I recently built and published a plugin that integrates Apple Mail with OpenClaw (an AI automation platform), allowing AI agents to monitor and respond to emails with per-thread session isolation.

🎯 The Problem

OpenClaw and Hermes are powerful AI automation platforms, but they lacked native Apple Mail integration on macOS. Users wanted to:

  • Monitor multiple email accounts
  • Have AI agents automatically respond to emails
  • Maintain conversation context across email threads
  • Keep different email conversations isolated

💡 The Solution

I built @jehadurre/openclaw-apple-mail - a channel plugin that:

  • Connects to Apple Mail via AppleScript
  • Creates isolated sessions per email thread
  • Processes HTML emails intelligently
  • Supports multi-account configuration
  • Includes security features like sender allowlists

🛠️ Technical Stack

  • TypeScript - Type-safe development
  • AppleScript - Native macOS Mail.app integration
  • HTML Processing - DOMPurify, jsdom, sanitize-html, marked
  • Schema Validation - Zod for configuration validation

📦 Key Features

1. Per-Thread Session Isolation

Each email conversation gets its own isolated session, preventing context mixing:

// Each thread gets unique session ID
const sessionId = `apple-mail:${threadId}`;

2. Multi-Account Support

Configure multiple email accounts with independent settings:

{
  "channels": {
    "apple-mail": {
      "accounts": {
        "work": {
          "email": "work@company.com",
          "pollIntervalMs": 15000,
          "archiveOnReply": true
        },
        "personal": {
          "email": "personal@gmail.com",
          "pollIntervalMs": 60000
        }
      }
    }
  }
}

3. Security Features

  • Sender allowlist per account
  • HTML sanitization
  • AppleScript sandboxing

4. Smart HTML Processing

Automatically converts HTML emails to clean markdown:

  • Table extraction and conversion
  • Removes tracking pixels
  • Sanitizes malicious content
  • Preserves formatting for AI agents

📚 Publishing Journey

I published this plugin to multiple platforms:

1. npm Registry

npm install @jehadurre/openclaw-apple-mail

2. GitHub

  • Full source code
  • Issue tracking
  • Contribution guidelines
  • MIT License

3. ClawHub

openclaw plugins install @jehadurre/openclaw-apple-mail

4. OpenClaw Skill

Created a comprehensive setup skill:

clawhub install apple-mail-setup

The skill includes:

  • Installation guide
  • 5 configuration templates
  • Troubleshooting solutions
  • Best practices

🎓 Lessons Learned

1. Compiled Output Matters

ClawHub requires compiled JavaScript, not just TypeScript source. I had to:

  • Get compiled output from production deployment
  • Include index.js in the package
  • Update package.json to reference the compiled file

2. Skills Enhance Adoption

Creating a separate "skill" package that teaches users how to set up and use the plugin significantly improves the user experience.

3. Multi-Platform Publishing

Publishing to npm, GitHub, ClawHub, and creating documentation on GitHub Pages maximizes discoverability.

🚀 Usage Example

Here's how users set it up:

Step 1: Install

openclaw plugins install @jehadurre/openclaw-apple-mail
clawhub install apple-mail-setup

Step 2: Configure

Add to openclaw.json:

{
  "channels": {
    "apple-mail": {
      "enabled": true,
      "accounts": {
        "personal": {
          "email": "user@example.com",
          "mailboxAccount": "iCloud",
          "allowFrom": ["*"]
        }
      }
    }
  }
}

Step 3: Start

openclaw start

That's it! OpenClaw now monitors your email and can respond automatically.

📊 Architecture

User Email → Apple Mail.app
              ↓ (AppleScript)
           Plugin Monitor
              ↓
        Session Manager (per-thread isolation)
              ↓
         HTML Processor
              ↓
        OpenClaw/Hermes AI Agent
              ↓
          Response
              ↓ (AppleScript)
        Apple Mail.app → Send Reply

🔐 Security Considerations

  1. Sender Allowlist: Only process emails from trusted senders
  2. HTML Sanitization: Remove malicious content from HTML emails
  3. AppleScript Sandboxing: Limited access to Mail.app APIs
  4. No Credential Storage: Uses existing Apple Mail accounts

🌟 Future Enhancements

Planned features:

  • [ ] Smart reply suggestions
  • [ ] Attachment handling
  • [ ] Email categorization
  • [ ] Custom email templates
  • [ ] Integration with other channels

📖 Resources

🤝 Contributing

Contributions welcome! Check out the Contributing Guide.

💬 Feedback

Have you used AI automation with email? What features would you like to see? Let me know in the comments!


About Me: I'm Md. Jehadur Rahman (Emran), a developer passionate about AI automation and productivity tools. Find me on GitHub and my website.

License: MIT - Free to use, modify, and redistribute!