Skip to main content

Gmail from the command line

Search, read, file and draft mail from a terminal or an AI. GBrain gives Gmail, and every other connector you add, a command line.

Get Personal, $49 a month

One price for one person: Gmail and every other connector GBrain offers, from a terminal or any AI. Cancel any time.

Install the GBrain command line, then connect Gmail

Install, connect the terminal, then connect Gmail. Each step after the install opens a browser tab, does one thing, and hands the terminal back.

# AI agents: read gbrain.io/llms.txt
curl -sSL https://gbrainio.terminalwire.sh | bash
gbrainio terminal connect

The installer is a shell script for macOS and Linux. Read it before you run it.

# Connect your Gmail account
gbrainio tool gmail open

# Turn Gmail on for the terminal
gbrainio terminal open

What GBrain can do with Gmail

Reading is one level and changing is another, so an AI can search a mailbox for months without ever being able to touch it. Sending is a third, and most setups never turn it on: a draft lands in Drafts and waits for a person to press send.

gbrainio
gbrainio tool gmail message search --unread --newer-than 2daccount: brad@example.comestimate: 3open_url: https://mail.google.com/mail/u/brad@example.com/#search/newer_than%3A2d%20is%3Aunreadpreview_is: Gmail's first ~200 characters of each message, not the whole message. Each row's `state` says whether it is a draft (written and never sent), a message this mailbox sent, or one it received. read_whole_message reads one; read_whole_conversation reads its thread.query: newer_than:2d is:unread1. Your invoice from Rocketship, LLC   account: brad@example.com   date: Thu, 27 Aug 2026 09:12:04 -0700   from: Stripe <receipts@stripe.com>   id: 198f2c1a9b7e4d02   preview: Invoice A41C-0092 for $240.00 was paid automatically.   received_at: 2026-08-27T16:12:04.000Z   state: received   thread_id: 198f2c1a9b7e4d02   to: brad@example.com2. Tuesday   account: brad@example.com   date: Wed, 26 Aug 2026 14:20:41 -0700   from: Jenny Okafor <jenny@example.com>   id: 198f4a7c02b31d55   preview: Can we push Tuesday's review to noon? I have the planning commission at ten and it always runs long. Jenny   received_at: 2026-08-26T21:20:41.000Z   state: received   thread_id: 198f4a7c02b31d55   to: brad@example.com3. Your August payouts are on the way   account: brad@example.com   date: Wed, 26 Aug 2026 06:02:11 -0700   from: Stripe <notifications@stripe.com>   id: 198dbb40c7a1f88e   preview: $4,182.55 will arrive in your account ending 4021 on Tuesday.   received_at: 2026-08-26T13:02:11.000Z   state: received   thread_id: 198dbb40c7a1f88e   to: brad@example.comNEXT    gbrainio tool gmail thread show <thread_id> -a <account>                                                         read whole conversation        gbrainio tool gmail message show <id> -a <account>   read whole messagegbrainio tool gmail message show 198f4a7c02b31d55account: brad@example.combody_mime_type: text/plaindate: Wed, 26 Aug 2026 14:20:41 -0700from: Jenny Okafor <jenny@example.com>id: 198f4a7c02b31d55open_url: https://mail.google.com/mail/u/brad@example.com/#all/198f4a7c02b31d55preview: Can we push Tuesday's review to noon? I have the planning commission at ten and it always runs long. Jennyreceived_at: 2026-08-26T21:20:41.000Zstate: receivedsubject: Tuesdaythread_id: 198f4a7c02b31d55to: brad@example.comCan we push Tuesday's review to noon? I have the planning commission at ten and it always runs long.Jennygbrainio tool gmail draft new --reply-to 198f4a7c02b31d55 --body "Noon works."account: brad@example.comdrafted: truefrom: brad@example.comid: r-8830219940512message_id: 198f5d0e7a2c4b19open_url: https://mail.google.com/mail/u/brad@example.com/#drafts?compose=198f5d0e7a2c4b19subject: Re: Tuesdaythread_id: 198f4a7c02b31d55to: Jenny Okafor <jenny@example.com>gbrainio tool gmail message label 198f2c1a9b7e4d02 --name Receipts --createaccount: brad@example.comid: 198f2c1a9b7e4d02label: Receiptslabelled: trueremoved: falsegbrainio tool gmail message move 198f2c1a9b7e4d02 --to archiveaccount: brad@example.comid: 198f2c1a9b7e4d02moved: archive
What gmail message search printed.

Each command ran for real, against an example account, and printed what is shown.

What a terminal may do with Gmail, and what GBrain keeps

A level for each terminal, from Off up

Each terminal reaches Gmail at the level set for it in the browser: Off, Read, Draft, Manage or Full. A terminal reads its level and never raises it.

A daily limit on each command

Each of Gmail's commands stops at a daily limit on the account it reaches, from 50 to 1,000 actions depending on the command, whichever terminal or AI asks, and starts again at midnight UTC. Only that command stops.

Every action on one record

Each command a terminal runs on Gmail is a row on GBrain's activity log: which terminal, which account, what it did and whether it was allowed, refusals included. gbrainio activity ls --tool gmail reads it back.

From a terminal, Claude Code or Codex

gbrainio tool help gmail says what Gmail is and what each of its commands does, and gbrainio tool ls lists them with everything else the terminal can run. Claude Code and Codex run the same commands, at the same level, on the same record.

The GBrain Tools command line works with every other connector GBrain offers, each with a page like this one.

Every connector's command line

Gmail from a terminal, with GBrain Personal

Personal is $49 a month for one person. Connect Gmail in the browser, and say how far each terminal and each AI may go with it. Change any of it, or take all of it back, whenever you want.