Skill Overview
---
name: apple-mail-search
description: Fast Apple Mail search via SQLite on macOS. Search emails by subject, sender, date, attachments - results in ~50ms vs 8+ minutes with AppleScript. Use when asked to find, search, or list emails.
homepage: https://github.com/steipete/clawdbot
metadata: {"clawdbot":{"emoji":"📬","os":["darwin"],"requires":{"bins":["sqlite3"]}}}
---
# Apple Mail Search
Search Apple Mail.app emails instantly via SQLite. ~50ms vs 8+ minutes with AppleScript.
## Installation
```bash
# Copy mail-search to your PATH
cp mail-search /usr/local/bin/
chmod +x /usr/local/bin/mail-search
```
## Usage
```bash
mail-search subject "invoice" # Search subjects
mail-search sender "@amazon.com" # Search by sender email
mail-search from-name "John" # Search by sender name
mail-search to "recipient@example.com" # Search sent mail
mail-search unread # List unread emails
mail-search attachments # List emails with attachments
mail-search attachment-type pdf # Find PDFs
mail-search recent 7 # Last 7 days
mail-search date-range 2025-01-01 2025-01-31
mail-search open 12345 # Open email by ID
mail-search stats # Database statistics
```
## Options
```
-n, --limit N Max results (default: 20)
-j, --json Output as JSON
-c, --csv Output as CSV
-q, --quiet No headers
--db PATH Override database path
```
## Examples
```bash
# Find bank statements from last month
mail-search subject "statement" -n 50
# Get unread emails as JSON for processing
mail-search unread --json | jq '.[] | .subject'
# Find all PDFs from a specific sender
mail-search sender "@bankofamerica.com" -n 100 | grep -i statement
# Export recent emails to CSV
mail-search recent 30 --csv > recent_emails.csv
```
## Why This Exists
| Method | Time for 130k emails |
|--------|---------------------|
| AppleScript iteration | 8+ minutes |
| SpotlightBot Reviews(1)
Fast local search over apple mail database
This skill searches apple mail by reading the mail database directly, which makes lookups nearly instant compared with scripting the mail application. It supports searching by subject, sender name or address, recipients, unread status, attachments and attachment type, plus recent and date ranges. The constraints are firm. It only runs on macos and requires a local database binary plus a helper script copied onto the path. Because it reads the mail store directly rather than through the application, results depend on that store being present and readable, and any sandbox restriction will break it. It is strictly a search and read tool with no sending capability.
Use case: finding old invoices buried in a mail archive
Study Guides(1)
Search a mail archive in milliseconds
Mail Search queries the local mail database directly instead of driving the mail application. Over a large archive that is the difference between tens of milliseconds and several minutes, which is the whole reason the tool exists. ## What it does - Searches by subject, sender address, sender name, and recipient, and lists unread mail. - Finds messages with attachments and filters by attachment type, such as documents. - Supports a recent window, an explicit date range, opening a message by id, and database statistics. - Emits structured output for other tools, including a machine-readable format and a spreadsheet-friendly one. - Runs as a small script placed on the path, with only a database binary as a dependency. ## When it is the wrong choice It is specific to one desktop operating system and reads a local database, so remote or webmail archives are out of scope. It also needs an install step copying the script onto the path, and because it reads the local store, results only cover what has actually synced to this machine. ```bash mail-search subject "invoice" mail-search sender "@amazon.com" mail-search unread mail-search attachments mail-search recent 7 mail-search date-range 2025-01-01 2025-01-31 ``` ## Notes Raise the result limit when a first search truncates, since the default only returns a small page. Emit structured output when another tool will consume the results rather than parsing columns, and prefer an explicit date range when the window is known.
Quick Facts
Install
npx clawhub@latest install apple-mail-search