Skip to content
mail-top-senders logo

Mail Top Senders

mail-top-senders

Show who sends the most email, communication frequency analysis, and relationship mapping. Use when user asks who emails them most, top contacts, communication patterns, or wants to understand their email social graph. Arguments: optional time range (default: last 90 days), account filter, or "humans only" to exclude automated senders.

aashari/ai-agent-skills0installs6stars

SKILL.md

Full skill instructions

Mail Top Senders — Communication Frequency Analysis

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

Step 1: All senders ranked by volume

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)
# 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

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:

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:

RankNameAddressEmails ReceivedUnread

Top Automated Senders (noise):

ServiceCountType

Top Domains:

DomainCount

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.

More skills from aashari

mail-core logo
aashari/ai-agent-skills

mail-core

Background technical knowledge for reading Apple Mail data locally on macOS. Auto-loaded when any mail-* skill executes. Contains architecture, query patterns, and parsing techniques for ~/Library/Mail/V10/.

6 0
View
calendar-event logo
aashari/ai-agent-skills

calendar-event

Get full details of a specific event including attendees, description, video link, location, and recurrence. Use when user asks about a specific meeting or event details.

6 0
View
calendar-free logo
aashari/ai-agent-skills

calendar-free

Find free time slots in a day or week. Use when user asks when they're free, wants to schedule something, or needs to find an open time window.

6 0
View
calendar-attendees logo
aashari/ai-agent-skills

calendar-attendees

Find meetings with a specific person, or list attendees of a specific event. Use when user asks who is in a meeting, whether someone is invited, or what meetings they share with a person.

6 0
View
mail-accounts logo
aashari/ai-agent-skills

mail-accounts

List all Apple Mail synced accounts with email addresses, message counts, folder structure, and account types. Use when user asks what email accounts are synced, how many emails they have, or wants an overview of their mail setup.

6 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View