Give your AI agent controlled access to Mac Mail. Read-only inbox export + draft creation. No more, no less.
Most AI integrations with email ask for full mailbox access. mailgate takes the opposite approach: you define exactly what the agent can see and do, through two simple shell scripts.
- The agent reads only what you export.
- The agent writes only drafts you approve before sending.
No MCP server. No OAuth. No background sync. Just two scripts and a clear boundary.
Your Mac Mail
│
▼
export_inbox.sh ──▶ inbox/*.md ──▶ Claude reads & analyzes
│
▼
draft.md (Claude writes)
│
▼
create_draft.sh ──▶ Mac Mail draft
│
▼
You hit Send ✉️
- macOS with Mail.app configured
- Python 3
osascript(bundled with macOS)
No dependencies to install.
./export_inbox.shExports every message from your INBOX into inbox/mail_1.md, inbox/mail_2.md, etc.
Each file contains a frontmatter header and the full body:
---
index: 1
de: sender@example.com
sujet: Hello
date: Sunday, 12 April 2026 at 09:00:00
lu: Oui
---
Body of the email...Then ask your agent:
"Analyse my inbox and list the actions I need to take."
Fill in draft.md — or let your agent fill it in for you:
---
to: recipient@example.com
cc: another@example.com
subject: My subject
---
Body of the email here.
Best regards,Then run:
./create_draft.shThe draft opens in Mac Mail, ready to review and send.
mailgate/
├── export_inbox.sh # Exports INBOX → inbox/*.md
├── create_draft.sh # Pushes draft.md → Mac Mail draft
├── draft.md # The draft you or your agent fills in
└── inbox/ # Generated — one .md file per email
| mailgate | Full MCP access | |
|---|---|---|
| Agent reads all folders | ❌ | ✅ |
| Agent sends emails autonomously | ❌ | ✅ |
| You review before sending | ✅ | ❌ |
| Works offline | ✅ | depends |
| Setup complexity | minimal | moderate |
The tradeoff is intentional. Giving an agent read/write access to your mailbox is powerful — and risky. mailgate keeps the human in the loop at both ends.
- Change the mailbox: edit
export_inbox.shand replace"INBOX"with any mailbox name available in Mail.app. - Multiple recipients: add multiple
to:orcc:lines — coming soon. - Other mail clients: the AppleScript blocks can be adapted for Outlook or Airmail with minor changes.
MIT