co gmail
Read, reply, send, and search your own Gmail account right in the terminal — the same Gmail API your agents use, as a command.
This is your mailbox, not the agent's. It needs co auth google once, and it mirrors co outlook command for command.
Quick Start
That's the whole surface. Everything below is detail.
Setup
Opens the Google OAuth flow and saves GOOGLE_* credentials (access token, refresh token, scopes, email) to your project .env and ~/.co/keys.env. Tokens auto-refresh at the start of every command, so you authorize once.
Commands
co gmail — Show the inbox
With no subcommand you get your 10 most recent emails — same as co gmail inbox. A green ● marks unread. --last, -n changes the count, --unread, -u filters to unread only.
Emails are numbered, and numbers mean your last listing — co gmail read 3 opens the third row of the table you just saw. Running co gmail again renumbers.
co gmail read <#> — Read one email
Takes a listing number or a full message id. Prints the headers in a panel and the body below it, then marks the email read — only when your token carries gmail.modify; a read-only token skips that step.
co gmail reply <#> <message> — Reply
Threaded — the reply goes back on the original conversation. A message of - reads the body from stdin.
co gmail send <to> <subject> <message> — Send
Recipients are comma-separated; --cc and --bcc take the same form. A message of - reads the body from stdin, which is how you send anything long or multi-line without fighting shell quoting.
co gmail sent — Recently sent
A read-only listing — it does not touch the numbering used by read and reply.
co gmail search <query> — Search
Takes full Gmail query syntax, not just plain words. Matches are numbered exactly like the inbox, so co gmail read <#> works on search results too.
Piping
In a terminal you get a Rich table with truncated columns. When the output is piped, you get the plain listing with full message ids instead, so scripts and agents never receive a truncated value.
Same Functions, in Your Agent
The CLI is a thin wrapper over the Gmail tool — anything co gmail does, your agent can do too:
Or call the same methods directly:
Troubleshooting
- • "Google account not connected" → run
co auth google. - • Missing Gmail scopes → run
co auth googleagain to re-consent. - • "No email #N in your last listing" → the number is out of range or the listing changed; run
co gmailto refresh the numbering. - • Credentials found in one project but not another → fixed in 1.3.1; older versions read either the project
.envor~/.co/keys.env, never both.
See Also
- • co gdrive — the same shape for Google Drive
- • co outlook — the same surface for an Outlook mailbox
- • co email — your agent's own address, no OAuth needed
- • Gmail tool — the full method list for agents
- • co auth — connects the Google account
ConnectOnion