gmcli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gmail CLI

Gmail CLI

Command-line interface for Gmail operations.
用于Gmail操作的命令行界面。

Installation

安装

bash
npm install -g @mariozechner/gmcli
bash
npm install -g @mariozechner/gmcli

Setup

配置

Google Cloud Console (one-time)

Google Cloud Console(一次性操作)

  1. Create a new project (or select existing)
  2. Enable the Gmail API
  3. Set app name in OAuth branding
  4. Add test users (all Gmail addresses you want to use)
  5. Create OAuth client:
    • Click "Create Client"
    • Application type: "Desktop app"
    • Download the JSON file
  1. 创建新项目(或选择现有项目)
  2. 启用Gmail API
  3. 在OAuth品牌设置中设置应用名称
  4. 添加测试用户(所有你想使用的Gmail地址)
  5. 创建OAuth客户端
    • 点击“创建客户端”
    • 应用类型:“桌面应用”
    • 下载JSON文件

Configure gmcli

配置gmcli

First check if already configured:
bash
gmcli accounts list
If no accounts, guide the user through setup:
  1. Ask if they have a Google Cloud project with Gmail API enabled
  2. If not, walk them through the Google Cloud Console steps above
  3. Have them download the OAuth credentials JSON
  4. Run:
    gmcli accounts credentials ~/path/to/credentials.json
  5. Run:
    gmcli accounts add <email>
    (use
    --manual
    for browserless OAuth)
首先检查是否已配置:
bash
gmcli accounts list
如果没有账户,引导用户完成设置:
  1. 询问用户是否拥有已启用Gmail API的Google Cloud项目
  2. 如果没有,引导用户完成上述Google Cloud Console步骤
  3. 让用户下载OAuth凭据JSON文件
  4. 运行:
    gmcli accounts credentials ~/path/to/credentials.json
  5. 运行:
    gmcli accounts add <email>
    (使用
    --manual
    参数进行无浏览器OAuth验证)

Usage

使用方法

Run
gmcli --help
for full command reference.
Common operations:
  • gmcli <email> search "<query>"
    - Search emails using Gmail query syntax
  • gmcli <email> thread <threadId>
    - Read a thread with all messages
  • gmcli <email> send --to <emails> --subject <s> --body <b>
    - Send email
  • gmcli <email> labels list
    - List all labels
  • gmcli <email> drafts list
    - List drafts
运行
gmcli --help
获取完整命令参考。
常见操作:
  • gmcli <email> search "<query>"
    - 使用Gmail查询语法搜索邮件
  • gmcli <email> thread <threadId>
    - 阅读包含所有消息的对话线程
  • gmcli <email> send --to <emails> --subject <s> --body <b>
    - 发送邮件
  • gmcli <email> labels list
    - 列出所有标签
  • gmcli <email> drafts list
    - 列出草稿

Data Storage

数据存储

  • ~/.gmcli/credentials.json
    - OAuth client credentials
  • ~/.gmcli/accounts.json
    - Account tokens
  • ~/.gmcli/attachments/
    - Downloaded attachments
  • ~/.gmcli/credentials.json
    - OAuth客户端凭据
  • ~/.gmcli/accounts.json
    - 账户令牌
  • ~/.gmcli/attachments/
    - 已下载的附件