emailcli

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

email

Your mailbox for your AI agent: Microsoft 365, Gmail, Google Workspace and IMAP servers, behind one CLI and an MCP server. The agent reads mail, drafts replies and (only if you allow it) sends. It works under a policy it cannot change, every write is logged, and message bodies are handed over as untrusted data, never as instructions. New mail wakes the agent within about a minute.

Tokens and passwords stay on your machine. There is no hosted service.

Pick your path

you run quickstart the agent uses new mail arrives by
Hermes on Kubernetes A the email CLI + skill email watch in its own pod
Hermes on one machine (VPS, Mac, Raspberry Pi) B the email CLI + skill email watch as a systemd / launchd service
Claude Code, Codex, or another MCP client C MCP tools you ask; or watch → your webhook

Each takes about 30 minutes, most of it connecting the mailbox. All three need a mailbox you can log in to:

mailbox provider you need guide
Microsoft 365 msgraph an app registration in your Entra tenant (10 min, admin) microsoft-365-setup.md
personal Gmail imap an app password (2-step verification on) gmail-personal-setup.md
Google Workspace gmail a GCP project with a Desktop OAuth client google-workspace-setup.md
iCloud, Fastmail, QQ, 163, Alibaba Mail, Mailu, any IMAP/SMTP imap an app password imap-presets.md

After each step, email doctor --format text checks the install, the policy, each login and the watch setup, and says how to fix what fails.

Try it first (no mailbox, 2 minutes)

curl -fsSL https://github.com/james-tronai/email-cli/releases/latest/download/install.sh | sh
export EMAIL_CONFIG_DIR=/tmp/email-try/config EMAIL_STATE_DIR=/tmp/email-try/state
email auth login -a demo --provider fake --mode draft -q      # a built-in pretend mailbox
curl -fsSL https://raw.githubusercontent.com/james-tronai/email-cli/main/docs/policy/draft.toml \
  -o /tmp/email-try/config/policy.toml                          # without a policy, everything is read-only
email list --format text
email get fake-0002 --format text                # hidden text in the HTML is removed and flagged
email draft reply fake-0002 --body "Thanks"
email send fake-0004                             # exit 4: the draft policy does not send

A. Hermes on Kubernetes

For Hermes running as a Deployment with HERMES_HOME on a PVC. The chart adds email, the skill, the triage cron job and a watch pod next to your Deployment; it does not change the Deployment.

  1. Install the chart, starting from examples/values.yaml:

    helm install alice-email oci://ghcr.io/james-tronai/charts/hermes-email -n hermes -f values.yaml
    
  2. Change the Hermes Deployment: mount the chart's ConfigMap at /etc/email, put /opt/data/.local/bin on PATH, set WEBHOOK_ENABLED=true and WEBHOOK_SECRET, merge email hermes config into config.yaml, restart.

  3. Log in from the Hermes container (the guides above have the values):

    kubectl -n hermes exec -it deploy/hermes-alice -c hermes -- \
      email auth login -a work --provider msgraph --mode draft --tenant <tenant-id> --client-id <client-id> --manual
    kubectl -n hermes rollout restart deploy/alice-email-watch
    
  4. Check: kubectl -n hermes exec deploy/hermes-alice -c hermes -- email doctor --format text.

Details for each step: docs/hermes.md § A and the chart README.

B. Hermes on one machine

For Hermes installed with its own installer (HERMES_HOME at ~/.hermes), on Linux or macOS.

  1. Install email (or brew install james-tronai/tap/email):

    curl -fsSL https://github.com/james-tronai/email-cli/releases/latest/download/install.sh | sh
    
  2. Log in to your mailbox (the guides above), for example:

    email auth login -a work --provider msgraph --mode draft --tenant <tenant-id> --client-id <client-id>
    printf '%s' "$APP_PASSWORD" | email auth login -a gmail --provider imap --username you@gmail.com --mode draft --password-stdin
    
  3. Connect Hermes: the skill, a draft policy, the watch service and the triage cron job reporting to you:

    email hermes install --deliver telegram:123456789 --format text   # or discord:<channel id>, …
    
  4. Merge the printed snippet into ~/.hermes/config.yaml and restart Hermes.

  5. Check: email doctor --format text --notify-url http://127.0.0.1:8644/webhooks/email.

Details: docs/hermes.md § B.

A and B: send a test mail to the mailbox from another address, and leave it unread. Within 60 to 90 seconds Hermes messages you about it. Ask it to draft a reply; it gives you the draft and a link, and you send it.

C. Claude Code, Codex and other MCP clients

  1. Install and log in as in B, steps 1 and 2.

  2. Add the MCP server:

    claude mcp add email -- email mcp                      # Claude Code
    codex mcp add email -- email mcp                       # Codex
    

    Any other client: command email, arguments mcp (stdio). For an agent on another machine, email mcp --http serves Streamable HTTP with a bearer token.

  3. Ask the agent to "check my mail", then to "draft a reply to the newest message". It uses the email tools, shows you the draft and its link, and sends nothing unless you ask.

Details, HTTP setup and the tool list: docs/mcp.md. An agent with a shell can also run email directly; email hermes skill prints the instructions Hermes uses, which suit any agent. To be told about new mail, run email watch against your own webhook.

What the agent can do

You set this in a policy file, ~/.config/email/policy.toml. Start from a template in docs/policy/:

template the agent may
read read and search
draft (recommended) also write drafts, mark, move and label; never send
send-reply-only also send replies in existing threads, to at most 5 recipients
send-open also send new messages, to at most 10 recipients

Sending also needs the account logged in with --mode send, and the skill and the MCP server tell the agent to send only a draft you have seen and asked it to send. Trash and delete stay off unless you turn them on.

The policy binds the agent only where the agent cannot edit it: the Helm chart mounts it read-only. On one machine Hermes's terminal runs as you, so there the policy stops mistakes and injected instructions acting through email, not an agent determined to get around it (the skill tells it never to touch the file). The hard limit there is the login: a Microsoft 365 account logged in with --mode draft cannot send at all. Every write and every denial goes to ~/.local/state/email/audit.jsonl. More: docs/safety.md.

Documentation

Development

task check      # gofmt, vet, race tests
task build

License

Apache License 2.0; see LICENSE. Copyright 2026 James Tan.

Documentation

Overview

Package emailcli holds the files that ship inside the binary, so that `email hermes files` and `email hermes install` write exactly what was released: the agent skill, the Hermes integration and the policy templates.

Index

Constants

This section is empty.

Variables

View Source
var EmailSkill []byte

EmailSkill is the agent skill (skills/email/SKILL.md).

View Source
var HermesCronJob []byte

HermesCronJob is the email triage cron job for `email hermes seed-cron`.

View Source
var HermesRouteScript []byte

HermesRouteScript is the Hermes webhook route script for `email watch`.

View Source
var PolicyTemplates embed.FS

PolicyTemplates holds docs/policy/<name>.toml.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
email command
internal
audit
Package audit appends one JSON line per write operation (and per policy denial) to audit.jsonl in the state directory.
Package audit appends one JSON line per write operation (and per policy denial) to audit.jsonl in the state directory.
auth
Package auth stores account metadata and provider tokens, and enforces the account lock (the mailbox a token belongs to must match the one recorded at login).
Package auth stores account metadata and provider tokens, and enforces the account lock (the mailbox a token belongs to must match the one recorded at login).
auth/oauthflow
Package oauthflow runs the browser half of an OAuth 2.0 authorization code + PKCE login for a public client.
Package oauthflow runs the browser half of an OAuth 2.0 authorization code + PKCE login for a public client.
cli
Package cli wires cobra commands to the service layer.
Package cli wires cobra commands to the service layer.
errs
Package errs defines the CLI's typed errors and their exit codes.
Package errs defines the CLI's typed errors and their exit codes.
hermes
Package hermes connects email to a Hermes agent: it writes the skill and the webhook route script into HERMES_HOME, seeds the triage cron job through the `hermes` CLI, and renders the watch service and the config.yaml snippet.
Package hermes connects email to a Hermes agent: it writes the skill and the webhook route script into HERMES_HOME, seeds the triage cron job through the `hermes` CLI, and renders the watch service and the config.yaml snippet.
mailmime
Package mailmime writes and reads RFC 5322 / MIME messages for the providers that deal in raw messages (gmail drafts, imap).
Package mailmime writes and reads RFC 5322 / MIME messages for the providers that deal in raw messages (gmail drafts, imap).
policy
Package policy is the gate every operation passes through.
Package policy is the gate every operation passes through.
provider
Package provider defines the unified mail model and the capability interfaces that each backend (msgraph, gmail, imap, fake) implements.
Package provider defines the unified mail model and the capability interfaces that each backend (msgraph, gmail, imap, fake) implements.
provider/fake
Package fake is an in-memory provider for tests and for trying the CLI without a real mailbox.
Package fake is an in-memory provider for tests and for trying the CLI without a real mailbox.
provider/gmail
Package gmail implements the provider interfaces on the Gmail REST API (Google Workspace accounts), with OAuth auth code + PKCE login.
Package gmail implements the provider interfaces on the Gmail REST API (Google Workspace accounts), with OAuth auth code + PKCE login.
provider/imap
Package imap is the provider for mailboxes reached over IMAP and SMTP with a password: personal Gmail with an app password, or any IMAP server.
Package imap is the provider for mailboxes reached over IMAP and SMTP with a password: personal Gmail with an app password, or any IMAP server.
provider/msgraph
Package msgraph implements the provider interfaces on Microsoft Graph (Microsoft 365 / Exchange Online) with delegated, device-code auth.
Package msgraph implements the provider interfaces on Microsoft Graph (Microsoft 365 / Exchange Online) with delegated, device-code auth.
service
Package service is the layer between the CLI and providers.
Package service is the layer between the CLI and providers.
watch
Package watch is `email watch`: a long-running process that waits for new mail and wakes the agent with one HTTP notification per batch, so the agent spends no tokens while nothing arrives.
Package watch is `email watch`: a long-running process that waits for new mail and wakes the agent with one HTTP notification per batch, so the agent spends no tokens while nothing arrives.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL