mail

mail is a command for coding agents from omarshahine/apple-pim. It costs 27 tokens per session (2,095 once invoked), scanned A, original, MIT.

A command for managing messages in the macOS Mail app. It can list accounts and mailboxes, read and search messages, send or reply to mail, change flags, move or delete messages, and check sender authentication.

In plain words
What is it for?
Use it to find or read messages, manage inbox organisation, send replies, update message flags, delete mail, and verify authentication details.
Why use it?
It brings common Mail tasks into an agent-controlled workflow instead of requiring each action through the Mail app interface.

Command

Part of the apple-pim plugin — 16 skills, 7 commands, 1 agent shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/omarshahine/apple-pim/mail
Clone the repo
git clone --depth 1 https://github.com/omarshahine/apple-pim

Or install apple-pim, the plugin that ships this one along with the rest of its 16 skills, 7 commands, 1 agent.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mail

README.md
[![agentmods](https://agentmods.dev/badge/commands/omarshahine/apple-pim/mail.svg)](https://agentmods.dev/commands/omarshahine/apple-pim/mail)
Your own site
<a href="https://agentmods.dev/commands/omarshahine/apple-pim/mail"><img src="https://agentmods.dev/badge/commands/omarshahine/apple-pim/mail.svg" alt="Measured on agentmods" height="20"></a>
Per session 27 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,095 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00027 $0.02095
Opus 5 $0.00014 $0.01047
Sonnet 5 $0.00005 $0.00419
Haiku 4.5 $0.00003 $0.00210

Measured 4d ago against content hash ca2506e46711, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mail scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/mail.md · 196 lines

How it starts

The opening of the file, as written. The whole thing — 196 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Mail Management

Manage macOS Mail.app messages. Reads (accounts, mailboxes, messages, get, search) use a fast direct-SQLite path against Mail's local Envelope Index (milliseconds, works with Mail.app closed, needs Full Disk Access) and fall back to JXA automatically. Mutations and content search go through Mail.app via JXA/AppleScript, which requires Mail.app to be running.

Available Operations

When the user runs this command, determine which operation they need and use the mail tool with the appropriate action:

List Accounts

Use mail with action accounts to show all configured mail accounts.

List Mailboxes

Use mail with action mailboxes to list mailboxes with unread and total message counts:

  • Optional: account (filter by account name)

List Messages

Use mail with action messages to list messages in a mailbox:

  • Default mailbox: INBOX
  • Parameters: mailbox, account, limit (default: 25), filter (unread, flagged, all)

Get Message

Use mail with action get to get a single message with full body content:

  • Required: id (RFC 2822 message ID)
  • Optional: mailbox, account (hints for faster lookup)
  • Optional: format (plain default, or markdown for HTML-to-markdown conversion)

Search Messages

Use mail with action search to find messages by subject, sender, or content:

  • Required: query (search term)
  • Optional: field (subject, sender, content, all), mailbox, account, limit, since (ISO 8601 date)

Send Message

Use mail with action send to send an email through Mail.app:

  • Required: to (array of recipient addresses), subject (email subject), body (plain text body)
  • Optional: cc, bcc, from (sender address for account selection)
  • Uses AppleScript to compose and send via Mail.app's outgoing message

Reply to Message

Use mail with action reply to reply to a message with proper threading:

  • Required: id (RFC 2822 message ID), body (reply text)
  • Optional: mailbox, account (hints for faster lookup)
  • Uses Mail.app's reply verb which sets In-Reply-To, References headers, and quotes the original

Read the full file on GitHub · 196 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 196 lines · 27 tokens per session scan A ca2506e46711

Subscribe to this mod's changes

mail is a command published in the GitHub repository omarshahine/apple-pim (50 stars, last pushed today), licensed MIT. It adds 27 tokens to every session and 2,095 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.