pip install mailcode
Turn your email inbox into a remote control for AI coding agents. MailCode bridges OpenCode and Claude Code — send tasks, receive results, and inject commands, all through any email account. Zero third-party dependencies.
Built for developers who need to stay in control of their AI agents, from anywhere.
Cron-based email scheduling for recurring automation — nightly backups, daily reports, automated code reviews.
Start an interactive REPL with the AI directly from your terminal — no email needed. Resume any existing session created by the relay, or start a fresh conversation.
Conversations stored as individual files on disk. Resume across serve and chat modes, or pick up where you left off after a restart. Sessions auto-expire based on configurable TTL.
DKIM/SPF authentication, sender whitelist, command blacklist, and auto-expiring sessions. Every incoming email is verified before execution.
Session mode for persistent multi-turn conversations + stateless mode for one-shot commands. Sticky working directory in session mode.
Gmail, Outlook, QQMail, 126Mail — IMAP IDLE long connection for instant command delivery.
MailCode creates a simple bridge between your email inbox and AI coding agents.
A coding task or command, sent from any email client — phone, tablet, or laptop.
MailCode polls your inbox in real time via IMAP IDLE, detecting new messages instantly.
Commands are forwarded to a claude -p subprocess. The AI works on your task and streams the response back.
Task completes? You receive an email with the AI's response. Reply to continue the conversation.
Choose between multi-turn conversations or one-shot commands — whatever fits your workflow.
MailCode groups emails by subject into persistent sessions. Reply to the same email thread and the AI remembers context — no need to repeat yourself. The working directory (cwd) is sticky: set it once in your first email and all follow-ups reuse it. Sessions survive restarts and can be resumed via mailcode chat --session-id <id>.
Set session.enabled = false in your config for simple single-reply mode. Each email is processed independently — no conversation history is carried over. The cwd directive is parsed fresh every time. Perfect for scheduled tasks or quick one-off queries.
Configure SMTP and IMAP for your preferred email service.
Developers use MailCode to stay connected to their codebase no matter where they are.
Send emails from your phone to trigger AI coding tasks while commuting or away from your desk. Review results and iterate — all from your pocket.
Configure cron-like email triggers for nightly backups, dependency updates, or automated refactoring — without keeping a laptop open.
Production issue while traveling? Send an email with the hotfix command. MailCode cold-starts your agent, applies the patch, and confirms the result.
MailCode is fully open source under the MIT License — free for everyone, for any purpose.
Contributions, issues, and stars are welcome on GitHub.
Requires Python 3.9+ and an AI agent CLI (Claude Code or OpenCode).
pip install mailcode
mailcode config init
mailcode serve
Run mailcode config init to configure your email credentials, then start the relay with mailcode serve.
Install MailCode in one command and bridge your email to AI in minutes. Completely free and open source.
New releases, tips & tricks, and AI agent best practices — once a month, no spam.
Zero spam. Unsubscribe anytime. By subscribing, you agree to receive MailCode updates.