home / skills / openclaw / skills / apple-mail-search-safe

apple-mail-search-safe skill

/skills/gumadeiras/apple-mail-search-safe

This skill enables fast and safe Apple Mail search with full body content support using SQLite-based queries.

npx playbooks add skill openclaw/skills --skill apple-mail-search-safe

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
2.4 KB
---
name: apple-mail-search
description: Fast & safe Apple Mail search with body content support.
homepage: https://clawdhub.com/gumadeiras/apple-mail-search-safe
repository: https://github.com/gumadeiras/apple-mail-search-cli
metadata: {"clawdbot":{"emoji":"📧","requires":{"bins":["fruitmail"]},"install":[{"id":"node","kind":"node","package":"apple-mail-search-cli","bins":["fruitmail"],"label":"Install fruitmail CLI (npm)"}]}}
---

# Fruitmail (Fast & Safe)

Fast SQLite-based search for Apple Mail.app with full body content support.

## Installation

```bash
npm install -g apple-mail-search-cli
```

## Usage

```bash
# Complex search
fruitmail search --subject "invoice" --days 30 --unread

# Search by sender
fruitmail sender "@amazon.com"

# List unread emails
fruitmail unread

# Read full email body (supports --json)
fruitmail body 94695

# Open in Mail.app
fruitmail open 94695

# Database stats
fruitmail stats
```

## Commands

| Command | Description |
|---------|-------------|
| `search` | Complex search with filters |
| `sender <query>` | Search by sender email |
| `unread` | List unread emails |
| `body <id>` | Read full email body (AppleScript) |
| `open <id>` | Open email in Mail.app |
| `stats` | Database statistics |

## Search Options

```
--subject <text>   Search subject lines
--days <n>         Last N days
--unread           Only unread emails
--limit <n>        Max results (default: 20)
--json             Output as JSON
--copy             Copy DB before query (safest mode)
```

## Examples

```bash
# Find bank statements from last month
fruitmail search --subject "statement" --days 30

# Get unread emails as JSON
fruitmail unread --json | jq '.[] | .subject'

# Find emails from Amazon
fruitmail sender "@amazon.com" --limit 50
```

## Performance

| Method | Time for 130k emails |
|--------|---------------------|
| AppleScript (full iteration) | 8+ minutes |
| SQLite (this tool) | **~50ms** |

## Technical Details

- **Database:** `~/Library/Mail/V{9,10,11}/MailData/Envelope Index`
- **Query method:** SQLite (read-only) + AppleScript (body content)
- **Safety:** Read-only mode prevents modification; optional `--copy` mode available

## Notes

- **macOS only** — queries Apple Mail.app's local database
- **Read-only** — can search/read but cannot compose/send
- **To send emails:** Use the `himalaya` skill (IMAP/SMTP)

## Source

https://github.com/gumadeiras/apple-mail-search-cli

Overview

This skill provides fast, read-only search of Apple Mail using a local SQLite index with full body-content support. It is designed for macOS users who need quick, safe queries across large Mail stores without modifying data. The tool emphasizes speed, safety, and practical command-line filters for day-to-day email triage.

How this skill works

The skill reads Apple Mail's Envelope Index (SQLite) in read-only mode to execute fast queries across subjects, senders, dates, and read/unread flags. When full message bodies are required it retrieves content via AppleScript, and an optional copy-before-query mode creates a safe replica of the database for extra protection. Outputs can be returned as JSON for scripting or plain text for quick inspection.

When to use it

  • Quickly locate messages by subject, sender, or date range without opening Mail.app
  • Automating email triage or reporting with JSON output in scripts and pipelines
  • Inspecting unread messages or extracting full body content for specific message IDs
  • Running frequent searches on large mail stores where AppleScript-only methods are too slow
  • Checking database stats or verifying local Mail store contents safely

Best practices

  • Run queries in read-only mode; use the --copy option when you want an extra safety margin
  • Prefer JSON output for automation and piping into jq or other processors
  • Limit result sets with --limit during exploratory searches to reduce noise
  • Combine filters (subject, days, unread) to narrow results quickly
  • Test body retrieval on sample message IDs before bulk processing to confirm format

Example use cases

  • Find all invoice or statement emails from the past 30 days with subject filters
  • Generate a JSON list of unread messages for integration with notification scripts
  • Search for all messages from @amazon.com and export the first 50 results
  • Open a specific message directly in Mail.app when you need the native UI
  • Inspect database statistics to monitor mailbox growth and health

FAQ

Is this safe to run against my Mail database?

Yes — it operates in read-only mode by default. Use --copy to query a duplicate of the database for extra safety.

Can it return full message bodies?

Yes — bodies are retrieved via AppleScript on demand. Use body <id> or enable JSON output for structured results.