Skip to content

akjaouen/agent-mailgate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

mailgate

Give your AI agent controlled access to Mac Mail. Read-only inbox export + draft creation. No more, no less.

Philosophy

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.


How it works

Your Mac Mail
     │
     ▼
export_inbox.sh  ──▶  inbox/*.md  ──▶  Claude reads & analyzes
                                              │
                                              ▼
                                         draft.md  (Claude writes)
                                              │
                                              ▼
                             create_draft.sh  ──▶  Mac Mail draft
                                                        │
                                                        ▼
                                                   You hit Send ✉️

Requirements

  • macOS with Mail.app configured
  • Python 3
  • osascript (bundled with macOS)

No dependencies to install.


Usage

1. Export your inbox

./export_inbox.sh

Exports 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."


2. Create a draft

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.sh

The draft opens in Mac Mail, ready to review and send.


File structure

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

Why this approach

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.


Customisation

  • Change the mailbox: edit export_inbox.sh and replace "INBOX" with any mailbox name available in Mail.app.
  • Multiple recipients: add multiple to: or cc: lines — coming soon.
  • Other mail clients: the AppleScript blocks can be adapted for Outlook or Airmail with minor changes.

Licence

MIT

About

Give your AI agent controlled access to Mac Mail. Read-only inbox export + draft creation. No more, no less.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages