Use gog for Gmail/Calendar/Drive/Contacts/Sheets/Docs. Requires OAuth setup.
Setup (once)
gog auth credentials /path/to/client_secret.jsongog auth add you@gmail.com --services gmail,calendar,drive,contacts,docs,sheetsgog auth listCommon commands
gog gmail search 'newer_than:7d' --max 10gog gmail messages search "in:inbox from:ryanair.com" --max 20 --account you@example.comgog gmail get --account you@example.com get to fetch full body--format metadata for just headers, --format raw for raw RFC822gog gmail attachment --out /path/to/save gog gmail send --to a@b.com --subject "Hi" --body "Hello"gog gmail send --to a@b.com --subject "Hi" --body-file ./message.txtgog gmail send --to a@b.com --subject "Hi" --body-file -gog gmail send --to a@b.com --subject "Hi" --body-html "Hello
"gog gmail drafts create --to a@b.com --subject "Hi" --body-file ./message.txtgog gmail drafts send gog gmail send --to a@b.com --subject "Re: Hi" --body "Reply" --reply-to-message-id gog calendar events --from --to gog calendar create --summary "Title" --from --to gog calendar create --summary "Title" --from --to --event-color 7 gog calendar update --summary "New Title" --event-color 4 gog calendar colorsgog drive search "query" --max 10gog contacts list --max 20gog sheets get "Tab!A1:D10" --json gog sheets update "Tab!A1:B2" --values-json '[["A","B"],["1","2"]]' --input USER_ENTERED gog sheets append "Tab!A:C" --values-json '[["x","y","z"]]' --insert INSERT_ROWS gog sheets clear "Tab!A2:Z" gog sheets metadata --json gog docs export --format txt --out /tmp/doc.txt gog docs cat Calendar Colors
gog calendar colors to see all available event colors (IDs 1-11)--event-color flaggog calendar colors output):Email Formatting
--body-file for multi-paragraph messages (or --body-file - for stdin).--body-file pattern works for drafts and replies.--body does not unescape \n. If you need inline newlines, use a heredoc or $'Line 1\n\nLine 2'.--body-html only when you need rich formatting. for paragraphs,
for line breaks, for bold, for italic, for links,
/ for lists.```bash
gog gmail send --to recipient@example.com \
--subject "Meeting Follow-up" \
--body-file - <<'EOF'
Hi Name,
Thanks for meeting today. Next steps:
Best regards,
Your Name
EOF
```
```bash
gog gmail send --to recipient@example.com \
--subject "Meeting Follow-up" \
--body-html "
Hi Name,
Thanks for meeting today. Here are the next steps:
Best regards,
Your Name
```
Notes
Headless/EC2 setup: On headless machines (no TTY), gog needs GOG_KEYRING_PASSWORD set:
export GOG_KEYRING_PASSWORD=your-passwordEnvironment=GOG_KEYRING_PASSWORD=your-passwordgog auth keyring fileGOG_ACCOUNT=you@gmail.com to avoid repeating --account.--json plus --no-input.--values-json (recommended) or as inline rows.gog gmail search returns one row per thread; use gog gmail messages search when you need every individual email returned separately.共 1 个版本