apple-mail

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Apple Mail Skill

Apple Mail Skill

Search, read, and extract attachments from Apple Mail's local storage on macOS.
在macOS上搜索、读取并提取Apple Mail本地存储中的附件。

Tool

工具

apple-mail.sh
— a bash script that queries the Apple Mail SQLite envelope index and reads
.emlx
files from disk. Read-only — it never modifies mail data.
apple-mail.sh
— 一款bash脚本,用于查询Apple Mail的SQLite信封索引并从磁盘读取
.emlx
文件。只读模式——绝不会修改邮件数据。

Quick Reference

快速参考

bash
TOOL=~/Development/agent-stuff/skills/apple-mail/apple-mail.sh
bash
TOOL=~/Development/agent-stuff/skills/apple-mail/apple-mail.sh

Search emails

Search emails

$TOOL search --from "peter@" --subject "dinner" --limit 5 $TOOL search --after 2026-02-01 --has-attachment $TOOL search --body "invoice" --mailbox "INBOX" --unread $TOOL search --to "armin@" --before 2025-12-31
$TOOL search --from "peter@" --subject "dinner" --limit 5 $TOOL search --after 2026-02-01 --has-attachment $TOOL search --body "invoice" --mailbox "INBOX" --unread $TOOL search --to "armin@" --before 2025-12-31

Show message metadata, recipients, attachments, and summary

Show message metadata, recipients, attachments, and summary

$TOOL info 783660
$TOOL info 783660

Read the raw RFC822 email (headers + body)

Read the raw RFC822 email (headers + body)

$TOOL read 783660
$TOOL read 783660

Extract attachments to a temp directory (prints the path)

Extract attachments to a temp directory (prints the path)

$TOOL attachment 783660 # all attachments $TOOL attachment 783660 "Rechnung.pdf" # specific file
$TOOL attachment 783660 # all attachments $TOOL attachment 783660 "Rechnung.pdf" # specific file

List all mailboxes with counts

List all mailboxes with counts

$TOOL mailboxes
undefined
$TOOL mailboxes
undefined

Search Options

搜索选项

FlagDescription
--from <addr>
Sender address substring
--to <addr>
Recipient address substring
--subject <text>
Subject substring
--body <text>
Body/summary text substring
--mailbox <name>
Mailbox URL substring (e.g.
INBOX
,
Sent
,
Trash
)
--after <YYYY-MM-DD>
Received after date
--before <YYYY-MM-DD>
Received before date
--unread
Only unread messages
--flagged
Only flagged messages
--has-attachment
Only messages with attachments
--limit <n>
Max results (default: 20)
标记描述
--from <addr>
发件人地址子串
--to <addr>
收件人地址子串
--subject <text>
主题子串
--body <text>
正文/摘要文本子串
--mailbox <name>
邮箱URL子串(例如
INBOX
Sent
Trash
--after <YYYY-MM-DD>
接收日期晚于指定日期
--before <YYYY-MM-DD>
接收日期早于指定日期
--unread
仅显示未读邮件
--flagged
仅显示已标记邮件
--has-attachment
仅显示包含附件的邮件
--limit <n>
最大结果数(默认:20)

Output Format

输出格式

  • search
    returns pipe-delimited table with header row:
    id|sender|sender_name|subject|received|status|flagged|mailbox|attachments
  • info
    returns structured metadata sections
  • read
    outputs raw RFC822 email to stdout
  • attachment
    prints the temp directory path to stdout, file listing to stderr
  • search
    返回带表头的竖线分隔表格:
    id|sender|sender_name|subject|received|status|flagged|mailbox|attachments
  • info
    返回结构化的元数据章节
  • read
    将原始RFC822格式邮件输出到标准输出
  • attachment
    将临时目录路径输出到标准输出,文件列表输出到标准错误

Notes

注意事项

  • Message IDs are Apple Mail internal ROWIDs (integers), shown in the
    id
    column
  • .partial.emlx
    files contain headers only (body not downloaded);
    read
    warns about this
  • Attachments are copied to a temp directory under
    /tmp/
    ; clean up when done
  • The
    body
    search queries the
    summaries
    table (Apple Mail's plaintext preview), not the full email body
  • Mailbox URLs are percent-encoded (e.g.,
    %5BGmail%5D
    =
    [Gmail]
    ,
    %20
    = space)
  • Deleted messages are excluded from search by default
  • 邮件ID是Apple Mail内部的ROWID(整数),显示在
    id
    列中
  • .partial.emlx
    文件仅包含邮件头(正文未下载);
    read
    会对此发出警告
  • 附件会被复制到
    /tmp/
    下的临时目录;使用完成后请清理
  • body
    搜索查询的是
    summaries
    表(Apple Mail的纯文本预览),而非完整邮件正文
  • 邮箱URL是百分编码格式(例如
    %5BGmail%5D
    =
    [Gmail]
    %20
    = 空格)
  • 默认情况下,已删除邮件会被排除在搜索结果之外