skills/apple-mail/mail-accounts/SKILL.md
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.
npx skillsauth add aashari/ai-agent-skills mail-accountsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
List every account synced in Apple Mail with identity, type, and stats.
ls ~/Library/Mail/V10/ | grep -v MailData | grep -v "^$"
Query the most frequent recipient address (most reliable identity signal):
DB="$HOME/Library/Mail/V10/MailData/Envelope Index"
for UUID in $(ls ~/Library/Mail/V10/ | grep -v MailData); do
# Account type from mailbox URL prefix
TYPE=$(sqlite3 "$DB" "SELECT url FROM mailboxes WHERE url LIKE '%${UUID}%' LIMIT 1;" 2>/dev/null | grep -oE '^[a-z]+')
# Sender of Sent mail = this account's address (reliable; avoids mailing list CC pollution)
EMAIL=$(sqlite3 "$DB" "
SELECT a.address
FROM messages m
JOIN mailboxes mb ON m.mailbox=mb.ROWID
JOIN addresses a ON m.sender=a.ROWID
WHERE mb.url LIKE '%${UUID}%'
AND (mb.url LIKE '%Sent%' OR mb.url LIKE '%sent%')
AND a.address LIKE '%@%'
GROUP BY a.address ORDER BY COUNT(*) DESC LIMIT 1;" 2>/dev/null)
# Fallback if no Sent mail: most frequent To: recipient in INBOX
if [ -z "$EMAIL" ]; then
EMAIL=$(sqlite3 "$DB" "
SELECT a.address
FROM messages m
JOIN mailboxes mb ON m.mailbox=mb.ROWID
JOIN recipients r ON r.message=m.ROWID
JOIN addresses a ON r.address=a.ROWID
WHERE mb.url LIKE '%${UUID}%/INBOX%' AND r.type = 0
GROUP BY a.address ORDER BY COUNT(*) DESC LIMIT 1;" 2>/dev/null)
fi
# Total message count
TOTAL=$(sqlite3 "$DB" "
SELECT COUNT(*) FROM messages m
JOIN mailboxes mb ON m.mailbox=mb.ROWID
WHERE mb.url LIKE '%${UUID}%' AND m.deleted=0;" 2>/dev/null)
# Unread count
UNREAD=$(sqlite3 "$DB" "
SELECT COUNT(*) FROM messages m
JOIN mailboxes mb ON m.mailbox=mb.ROWID
WHERE mb.url LIKE '%${UUID}%' AND m.deleted=0 AND m.read=0;" 2>/dev/null)
echo "${UUID}|${TYPE}|${EMAIL}|${TOTAL}|${UNREAD}"
done
sqlite3 "$DB" "
SELECT DISTINCT url FROM mailboxes
WHERE url LIKE '%UUID_HERE%'
ORDER BY url;" 2>/dev/null
sqlite3 "$DB" "
SELECT mb.url,
strftime('%Y-%m', datetime(m.date_received,'unixepoch','localtime')) as month,
COUNT(*) as cnt
FROM messages m
JOIN mailboxes mb ON m.mailbox=mb.ROWID
WHERE mb.url LIKE '%UUID_HERE%' AND m.deleted=0
GROUP BY month ORDER BY month DESC LIMIT 24;" 2>/dev/null
Present as a table:
| Account | Type | Total | Unread | |---|---|---|---| | [email protected] | Gmail/IMAP | 58,996 | 42 | | [email protected] | Exchange | 68,466 | 7 |
Then list folder structure per account if helpful. Note accounts that have high unread counts as potentially needing attention.
data-ai
Show work emails only, filtered to Exchange/EWS accounts and corporate email domains. Digest with priorities. Use when user asks about work email, work inbox, or wants to separate work from personal mail. Arguments: optional date range or "today", "yesterday", "this week".
testing
Intelligent inbox triage — surface the most important emails across all accounts, prioritized by urgency and requiring attention. Use when user wants a smart overview of what needs their attention, asks "what's important in my email", or wants help deciding what to read first. Arguments: optional time window (default: last 48 hours) or account filter.
data-ai
Find flight bookings, hotel reservations, travel itineraries, and booking confirmations from email. Use when user asks about upcoming trips, travel plans, booking references, flight details, or hotel reservations. Arguments: optional destination, airline, date range, or booking service.
testing
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.