gmail

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gmail

Gmail

All scripts in
~/.cursor/skills/gmail/scripts/
. Run from anywhere.
所有脚本位于
~/.cursor/skills/gmail/scripts/
目录下,可在任意位置运行。

Account Management

账户管理

bash
undefined
bash
undefined

List linked accounts

列出已关联的账户

node accounts.mjs --list
node accounts.mjs --list

Link an account (runs browser OAuth flow)

关联一个账户(启动浏览器OAuth授权流程)

node accounts.mjs --link # links as "default" node accounts.mjs --link --account=work # links as named account
node accounts.mjs --link # 以"default"为名关联 node accounts.mjs --link --account=work # 以指定名称关联账户

Unlink an account

解除账户关联

node accounts.mjs --unlink --account=work

Account storage:
~/.cursor/skills/gmail/ ├── credentials.json # shared OAuth2 client (one for all accounts) └── accounts/ ├── default/ │ ├── token.json # access + refresh tokens ← SENSITIVE │ └── profile.json # cached email address └── work/ ├── token.json └── profile.json

**All scripts accept `--account=<name>` (default: `default`)**
node accounts.mjs --unlink --account=work

账户存储位置:
~/.cursor/skills/gmail/ ├── credentials.json # 共享OAuth2客户端信息(所有账户通用) └── accounts/ ├── default/ │ ├── token.json # 访问令牌+刷新令牌 ← 敏感信息 │ └── profile.json # 缓存的邮箱地址 └── work/ ├── token.json └── profile.json

**所有脚本均支持 `--account=<name>` 参数(默认值:`default`)**

One-Time Setup

一次性设置

bash
undefined
bash
undefined

1. Get credentials.json from Google Cloud Console:

1. 从Google Cloud Console获取credentials.json:

console.cloud.google.com → Gmail API → Credentials → OAuth Client ID → Desktop App → Download JSON

console.cloud.google.com → Gmail API → 凭据 → OAuth客户端ID → 桌面应用 → 下载JSON

mv ~/Downloads/client_secret_*.json ~/.cursor/skills/gmail/credentials.json
mv ~/Downloads/client_secret_*.json ~/.cursor/skills/gmail/credentials.json

2. Link your first account

2. 关联你的第一个账户

node ~/.cursor/skills/gmail/scripts/accounts.mjs --link
undefined
node ~/.cursor/skills/gmail/scripts/accounts.mjs --link
undefined

Scripts

脚本说明

list.mjs

list.mjs

bash
node list.mjs [--account=work] [--max=50] [--label=UNREAD] [--next-page=<token>]
bash
node list.mjs [--account=work] [--max=50] [--label=UNREAD] [--next-page=<token>]

search.mjs

search.mjs

bash
node search.mjs --query="from:stripe" [--account=work] [--max=20] [--next-page=<token>]
bash
node search.mjs --query="from:stripe" [--account=work] [--max=20] [--next-page=<token>]

Gmail query syntax: from: to: subject: is:unread has:attachment after:2026/03/01

Gmail查询语法:from: to: subject: is:unread has:attachment after:2026/03/01

undefined
undefined

read.mjs

read.mjs

bash
node read.mjs --id=<messageId> [--account=work]          # single message
node read.mjs --id=<threadId> --thread [--account=work]  # full thread
node read.mjs --id=<messageId> --raw                     # show raw HTML
bash
node read.mjs --id=<messageId> [--account=work]          # 读取单封邮件
node read.mjs --id=<threadId> --thread [--account=work]  # 读取完整邮件线程
node read.mjs --id=<messageId> --raw                     # 显示原始HTML内容

reply.mjs

reply.mjs

bash
node reply.mjs --message-id=<id> --body="Text" [--account=work]
node reply.mjs --message-id=<id> --html="<b>Hi</b>"
node reply.mjs --message-id=<id> --body="Hi" --cc="c@d.com" --bcc="e@f.com"
node reply.mjs --message-id=<id> --body="See attached" --attachments="/path/a.pdf"
bash
node reply.mjs --message-id=<id> --body="Text" [--account=work]
node reply.mjs --message-id=<id> --html="<b>Hi</b>"
node reply.mjs --message-id=<id> --body="Hi" --cc="c@d.com" --bcc="e@f.com"
node reply.mjs --message-id=<id> --body="See attached" --attachments="/path/a.pdf"

send.mjs

send.mjs

bash
node send.mjs --to="a@b.com" --subject="Hi" --body="Text" [--account=work]
node send.mjs --to="a@b.com" --subject="Hi" --html="<h1>Hello</h1>"
node send.mjs --to="a@b.com" --subject="Hi" --body="Hi" --cc="c@d.com" --bcc="e@f.com"
node send.mjs --to="a@b.com" --subject="Files" --body="See attached" --attachments="/path/a.pdf,/path/b.png"
bash
node send.mjs --to="a@b.com" --subject="Hi" --body="Text" [--account=work]
node send.mjs --to="a@b.com" --subject="Hi" --html="<h1>Hello</h1>"
node send.mjs --to="a@b.com" --subject="Hi" --body="Hi" --cc="c@d.com" --bcc="e@f.com"
node send.mjs --to="a@b.com" --subject="Files" --body="See attached" --attachments="/path/a.pdf,/path/b.png"

label.mjs

label.mjs

bash
node label.mjs --list [--account=work]
node label.mjs --id=<messageId> --mark-read [--account=work]
node label.mjs --id=<messageId> --mark-unread
node label.mjs --id=<messageId> --archive
node label.mjs --id=<messageId> --trash
node label.mjs --id=<messageId> --star / --unstar
node label.mjs --id=<messageId> --add-label=IMPORTANT
node label.mjs --id=<messageId> --remove-label=SPAM
bash
node label.mjs --list [--account=work]
node label.mjs --id=<messageId> --mark-read [--account=work]
node label.mjs --id=<messageId> --mark-unread
node label.mjs --id=<messageId> --archive
node label.mjs --id=<messageId> --trash
node label.mjs --id=<messageId> --star / --unstar
node label.mjs --id=<messageId> --add-label=IMPORTANT
node label.mjs --id=<messageId> --remove-label=SPAM

draft.mjs

draft.mjs

bash
node draft.mjs --list [--account=work]
node draft.mjs --create --to="a@b.com" --subject="Hi" --body="Text"
node draft.mjs --create --reply-to=<messageId> --body="Reply"   # To: auto-filled
node draft.mjs --read --id=<draftId>
node draft.mjs --send --id=<draftId>
node draft.mjs --delete --id=<draftId>
bash
node draft.mjs --list [--account=work]
node draft.mjs --create --to="a@b.com" --subject="Hi" --body="Text"
node draft.mjs --create --reply-to=<messageId> --body="Reply"   # 收件人自动填充
node draft.mjs --read --id=<draftId>
node draft.mjs --send --id=<draftId>
node draft.mjs --delete --id=<draftId>

Abuse Report Workflow

滥用报告处理流程

bash
node search.mjs --query="from:namecheap subject:abuse"
node read.mjs --id=<messageId> --thread
node reply.mjs --message-id=<id> --body="Dear Namecheap Legal & Abuse Team,

Thank you for your message regarding ticket <TICKET-ID>.

We have completed our investigation and taken the following actions:

1. The account in question has been permanently suspended.
2. The reported URL (hxxp:// <PROJECT-ID> [.] sites [.] blink [.] new/) has been deactivated and now returns an HTTP 410 response.
3. All content and deployments associated with this account have been removed.

Our platform has a strict Acceptable Use Policy and we act promptly on all reports.
The blink.new domain is fully compliant with your Terms of Service.

Please let us know if anything further is needed to close this case.

Best regards,
Kai Feng
CEO, Blink.new
support@blink.new"
bash
node search.mjs --query="from:namecheap subject:abuse"
node read.mjs --id=<messageId> --thread
node reply.mjs --message-id=<id> --body="Dear Namecheap Legal & Abuse Team,

Thank you for your message regarding ticket <TICKET-ID>.

We have completed our investigation and taken the following actions:

1. The account in question has been permanently suspended.
2. The reported URL (hxxp:// <PROJECT-ID> [.] sites [.] blink [.] new/) has been deactivated and now returns an HTTP 410 response.
3. All content and deployments associated with this account have been removed.

Our platform has a strict Acceptable Use Policy and we act promptly on all reports.
The blink.new domain is fully compliant with your Terms of Service.

Please let us know if anything further is needed to close this case.

Best regards,
Kai Feng
CEO, Blink.new
support@blink.new"

Cloud Setup

云端部署设置

bash
echo "GMAIL_CREDENTIALS=$(base64 -i ~/.cursor/skills/gmail/credentials.json)"
echo "GMAIL_TOKEN=$(base64 -i ~/.cursor/skills/gmail/accounts/default/token.json)"
Set as secrets in your cloud container. Scripts auto-detect env vars over files (default account only).
bash
echo "GMAIL_CREDENTIALS=$(base64 -i ~/.cursor/skills/gmail/credentials.json)"
echo "GMAIL_TOKEN=$(base64 -i ~/.cursor/skills/gmail/accounts/default/token.json)"
将上述内容设置为云容器中的密钥。脚本会自动优先检测环境变量而非本地文件(仅支持默认账户)。

Security

安全说明

  • credentials.json
    token.json
    文件已被设置为git忽略文件——切勿将其带出你的设备
  • 撤销访问权限:访问 https://myaccount.google.com/permissions → 找到你的应用 → 撤销