Gmail CLI for humans and agents. Read, search, reply, and send formatted emails from the terminal.
gm # inbox
gm read 19cfbc6564b511d2 # read email
gm search "from:bob invoice" # search
gm reply 19cfbc6564b511d2 "Thanks!" # plain text reply
gm send bob@x.com "Report" --md report.md # formatted email
- One binary, no config — wraps gws for OAuth, does everything else in Go
- Agent-friendly —
--jsonoutput on every command, deterministic exit codes, no interactive prompts - Markdown emails — renders via pandoc with clean inline CSS, no external templates
- Threading —
--replyattaches to Gmail threads correctly (threadId + In-Reply-To + References) - Attachments —
--attachfor any file type, repeatable
go install github.com/evoleinik/gm@latest
Or build from source:
git clone https://github.com/evoleinik/gm cd gm go build -o gm . cp gm ~/go/bin/ # or anywhere on PATH
gm # latest 10 gm 20 # latest 20 gm --json # machine-readable
gm read <message-id> # human-readable (shows attachments) gm read <id1> <id2> <id3> # batch read (parallel fetch) gm read <message-id> --json # full metadata + body + attachments gm read <message-id> --save # read + save attachments to current dir gm read <message-id> --save ~/dl # save attachments to specific dir
gm search "query" # Gmail search syntax gm search "from:bob" -n 5 # limit results gm search "has:attachment newer_than:7d" gm search "query" --full # body preview (500 chars) + attachments
gm reply <message-id> "message body" # plain text, threads correctly
# Plain text gm send to@email "Subject" --body "Hello" # Markdown (rendered to styled HTML) gm send to@email "Subject" --md document.md # Stdin echo "**bold** and *italic*" | gm send to@email "Subject" --md - # With attachments gm send to@email "Report" --md report.md --attach data.csv --attach chart.png # Threaded reply (attaches to existing Gmail thread) gm send to@email "Re: Topic" --md reply.md --reply 19cfbc6564b511d2 # CC, BCC gm send to@email "Subject" --body "Hi" --cc alice@x.com --bcc boss@x.com # Disable default BCC gm send to@email "Subject" --body "Hi" --no-bcc
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | User error (bad arguments) |
| 2 | gws error (auth, network, API) |
Single main.go, Go stdlib only (no dependencies). All Gmail API calls go through gws. MIME message building, base64 encoding, multipart assembly, and HTML stripping are done in pure Go.
gm ──→ gws (OAuth + Gmail API)
│
└──→ pandoc (markdown → HTML, only for --md)
MIT