# Mail Top Senders

> >-

- **Type:** Skill
- **Install:** `agentstack add skill-aashari-ai-agent-skills-mail-top-senders`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [aashari](https://agentstack.voostack.com/s/aashari)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [aashari](https://github.com/aashari)
- **Source:** https://github.com/aashari/ai-agent-skills/tree/main/skills/apple-mail/mail-top-senders

## Install

```sh
agentstack add skill-aashari-ai-agent-skills-mail-top-senders
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Mail Top Senders — Communication Frequency Analysis

Analysis period: **$ARGUMENTS** (default: last 90 days)

## Step 1: All senders ranked by volume
```bash
DB="$HOME/Library/Mail/V10/MailData/Envelope Index"
SINCE=$(($(date +%s) - 7776000))  # 90 days

sqlite3 "$DB" "
SELECT a.address, a.comment as name,
       COUNT(*) as total,
       SUM(CASE WHEN m.read=0 THEN 1 ELSE 0 END) as unread,
       MIN(datetime(m.date_received,'unixepoch','localtime')) as first,
       MAX(datetime(m.date_received,'unixepoch','localtime')) as latest
FROM messages m
JOIN addresses a  ON m.sender  = a.ROWID
JOIN mailboxes mb ON m.mailbox = mb.ROWID
WHERE m.date_received >= ${SINCE}
  AND m.deleted = 0
  AND mb.url NOT LIKE '%Spam%' AND mb.url NOT LIKE '%Trash%'
  AND mb.url NOT LIKE '%Sent%'
GROUP BY a.address
ORDER BY total DESC
LIMIT 50;" 2>/dev/null
```

## Step 2: Separate humans from automated senders
Use `automated_conversation` and `unsubscribe_type` columns (more reliable than address-pattern matching):
- `automated_conversation = 0` + `unsubscribe_type = 0` → real humans
- `automated_conversation = 1` → transactional (Jira, Slack, alerts)
- `automated_conversation = 2` OR `unsubscribe_type > 0` → bulk/newsletters (noise)

```bash
# Human senders only (automated_conversation = 0, no unsubscribe header)
sqlite3 "$DB" "
SELECT a.address, a.comment as name, COUNT(*) as cnt
FROM messages m
JOIN addresses a ON m.sender = a.ROWID
JOIN mailboxes mb ON m.mailbox = mb.ROWID
WHERE m.date_received >= ${SINCE}
  AND m.deleted = 0
  AND mb.url NOT LIKE '%Spam%' AND mb.url NOT LIKE '%Sent%'
  AND m.automated_conversation = 0
  AND m.unsubscribe_type = 0
GROUP BY a.address ORDER BY cnt DESC LIMIT 20;" 2>/dev/null
```

## Step 3: Domain-level analysis
```bash
sqlite3 "$DB" "
SELECT substr(a.address, instr(a.address,'@')+1) as domain,
       COUNT(*) as cnt
FROM messages m
JOIN addresses a ON m.sender = a.ROWID
JOIN mailboxes mb ON m.mailbox = mb.ROWID
WHERE m.date_received >= ${SINCE}
  AND m.deleted = 0
  AND mb.url NOT LIKE '%Spam%'
GROUP BY domain ORDER BY cnt DESC LIMIT 20;" 2>/dev/null
```

## Step 4: Thread participation (two-way communication)
Find senders you also replied to — true relationships vs. one-way communication:
```bash
sqlite3 "$DB" "
SELECT a.address, COUNT(*) as received
FROM messages m
JOIN addresses a ON m.sender = a.ROWID
JOIN mailboxes mb ON m.mailbox = mb.ROWID
WHERE m.date_received >= ${SINCE} AND m.deleted=0
  AND mb.url NOT LIKE '%Sent%'
GROUP BY a.address
ORDER BY received DESC LIMIT 30;" 2>/dev/null
```

## Output Format
**Top Email Relationships — [PERIOD]**

**Most Frequent Human Contacts:**
| Rank | Name | Address | Emails Received | Unread |
|---|---|---|---|---|

**Top Automated Senders (noise):**
| Service | Count | Type |
|---|---|---|

**Top Domains:**
| Domain | Count |
|---|---|

Insight: note anyone with high unread rate (you receive a lot but don't read → de-prioritize subscription?).
Note anyone with very recent last email who you haven't read → potential missed message.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [aashari](https://github.com/aashari)
- **Source:** [aashari/ai-agent-skills](https://github.com/aashari/ai-agent-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-aashari-ai-agent-skills-mail-top-senders
- Seller: https://agentstack.voostack.com/s/aashari
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
