Scriptable access to macOS Mail.app from the command line. List accounts, browse mailboxes, read and manage messages, search email, handle attachments, and send email — all with JSON output for automation. Built with Go and Cobra.

Commands

  • accounts — List all configured email accounts
  • mailboxes — Browse mailbox hierarchy
  • messages list — List messages with filters (unread, flagged, since date, limit)
  • messages read/flag/archive/move/delete — Manage individual messages
  • send — Send email with recipients, CC, subject, and body
  • search — Full-text search across mailboxes
  • attachments — List and save message attachments

Usage Examples

# List unread messages
mail-app-cli messages list --unread --limit 10

# Search for messages
mail-app-cli search "quarterly report"

# Send an email
mail-app-cli send --to user@example.com --subject "Hello" --body "Message"

# Save attachments from a specific sender
mail-app-cli messages list --from boss@work.com | \
  jq -r '.[].id' | \
  xargs -I {} mail-app-cli attachments save {}

Architecture

Uses Go + Cobra for the CLI framework and AppleScript/JXA for Mail.app interaction. All output is structured JSON, making it easy to pipe into jq for filtering, counting, CSV export, and scripting workflows. Requires macOS 12+.