/gmail/.
For Google OAuth setup, see Google Workspace Setup.
Config
Filesystem Layout
INBOX, SENT, STARRED). User-created labels
use their label name with spaces replaced by underscores.
Date Directories
Inside each label, messages are grouped into date subdirectories formatted asYYYY-MM-DD. The date is derived from the message’s
internalDate (epoch milliseconds) converted to a calendar date.
Message Files
Each message is stored as a.gmail.json file. The filename shape is:
__ and before
.gmail.json.
Attachments
Messages that have attachments get a companion subdirectory with the same base name (without.gmail.json). Decoded attachment
files are placed inside:
Cache
The Gmail resource usesIndexCacheStore (same as Slack, Discord,
and other resources). Index entries store label IDs, message IDs,
and message metadata. There is no separate content cache — file
content caching is handled by the workspace IOResult mechanism.
Example
examples/gmail/gmail.py for the full working example.
Finding IDs
Resource-specific commands require message IDs. These can be extracted from the filesystem:Working with Large Labels
Labels with many messages are split into date directories. Tips for efficient access:Shell Commands
Standard commands available on the mounted Gmail tree:| Command | Notes |
|---|---|
ls | List labels, dates, messages, attachments |
cat | Read message JSON or attachment content |
head / tail | First/last N lines |
grep / rg | Pattern search (file or directory level) |
jq | Query message JSON fields |
wc | Line/word/byte counts |
stat | File metadata (name, size, type) |
find | Recursive search with -name, -maxdepth |
tree | Directory tree view |
basename | Extract filename from path |
dirname | Extract directory from path |
realpath | Resolve path to absolute form |
nl | Number lines of output |
gws-gmail-send
Send a new email.
| Option | Required | Description |
|---|---|---|
--to | yes | Recipient email address |
--subject | yes | Email subject line |
--body | yes | Email body text |
gws-gmail-reply
Reply to a message.
| Option | Required | Description |
|---|---|---|
--message-id | yes | Gmail message ID |
--body | yes | Reply body text |
gws-gmail-reply-all
Reply-all to a message.
| Option | Required | Description |
|---|---|---|
--message-id | yes | Gmail message ID |
--body | yes | Reply body text |
gws-gmail-forward
Forward a message to another recipient.
| Option | Required | Description |
|---|---|---|
--message-id | yes | Gmail message ID |
--to | yes | Recipient email address |
gws-gmail-triage
Search and triage emails using Gmail query syntax.
| Option | Required | Description |
|---|---|---|
--query | yes | Gmail search query |
--max | no | Maximum number of results to return |
gws-gmail-read
Read a message by its ID.
| Option | Required | Description |
|---|---|---|
--id | yes | Gmail message ID |