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. Every command returns JSON for automation. The CLI is built with Go and Cobra.
What Remains Under Operator Control
The CLI uses the permissions already granted to Mail.app. Scripts or AI tools can call named commands, but the operator still controls credentials and authorizes consequential actions. A managed deployment would also define records and review requirements.
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+.