Skip to content
mail-accounts logo

Mail Accounts — Discover All Synced Accounts

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.

aashari/ai-agent-skills0installs6stars

SKILL.md

Full skill instructions

Mail Accounts — Discover All Synced Accounts

List every account synced in Apple Mail with identity, type, and stats.

Steps

1. Get all account UUIDs

ls ~/​Library/​Mail/​V10/ | grep -v MailData | grep -v "^$"

2. For each UUID, identify the email address and account type

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

3. List mailbox folders for each account

sqlite3 "$DB" "
  SELECT DISTINCT url FROM mailboxes
  WHERE url LIKE '%UUID_HERE%'
  ORDER BY url;" 2>/​dev/​null

4. Get per-account message volume over time

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

Output Format

Present as a table:

AccountTypeTotalUnread
[email protected]Gmail/​IMAP58,99642
[email protected]Exchange68,4667

Then list folder structure per account if helpful. Note accounts that have high unread counts as potentially needing attention.

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

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