Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/163-mail/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5,234 changes: 2,621 additions & 2,613 deletions assets/icon-sources.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions external_plugins/163-mail/.mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"mcpServers": {
"163-mail": {
"command": "node",
"args": [
"${CLAUDE_PLUGIN_ROOT}/scripts/mcp-server.mjs"
]
}
}
}
28 changes: 28 additions & 0 deletions external_plugins/163-mail/.zcode-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "163-mail",
"version": "0.3.4",
"description": "All-in-one NetEase Mail assistant (163 / 126 / yeah.net / 188 & Enterprise): check unread mail, search with Chinese-safe keywords, read cleaned text, save attachments safely, extract verification codes, save drafts, compose new mail, and reply with automatic threading and quoted originals—with two-phase preview confirmation before sending or moving. Supports multiple accounts via an auto-opened local setup page with built-in official authorization-code tutorials and an account manager. Zero external dependencies; credentials stay encrypted locally (Windows DPAPI / macOS Keychain) and connect directly to NetEase servers. Includes an offline self-check and demo.",
"description_i18n": {
"en": "All-in-one NetEase Mail assistant (163 / 126 / yeah.net / 188 & Enterprise): check unread mail, search with Chinese-safe keywords, read cleaned text, save attachments safely, extract verification codes, save drafts, compose new mail, and reply with automatic threading and quoted originals—with two-phase preview confirmation before sending or moving. Supports multiple accounts via an auto-opened local setup page with built-in official authorization-code tutorials and an account manager. Zero external dependencies; credentials stay encrypted locally (Windows DPAPI / macOS Keychain) and connect directly to NetEase servers. Includes an offline self-check and demo.",
"zh-CN": "网易邮箱收发一体助手(支持 163 / 126 / yeah.net / 188 及网易企业邮):查未读、按中文关键字搜邮件、看正文、安全存附件、提取登录验证码,也能存草稿、写新邮件和回复——回复自动串会话并引用原文,发信与移动邮件均经预览确认后执行。支持配置多个邮箱账号,首次配置自动弹出本机安全网页表单,内置官方授权码获取教程与直达链接,填完自动验证保存;后续说「换个账号」即可打开同一页面的账号管理视图,随时新增、删除或切换默认账号。零外部依赖,授权码仅加密保存于本机(Windows DPAPI / macOS 钥匙串),直连网易服务器不经任何第三方;自带离线自检与样例演示,无需账号即可确认功能正常。"
},
"author": {
"name": "gugulogs",
"url": "https://github.com/gugulogs"
},
"license": "MIT",
"keywords": [
"netease",
"163",
"126",
"yeah",
"qiye-163",
"email",
"mail",
"imap",
"smtp",
"mcp"
],
"skills": "./skills",
"mcpServers": "./.mcp.json"
}
21 changes: 21 additions & 0 deletions external_plugins/163-mail/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 gugulogs (https://github.com/gugulogs)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
77 changes: 77 additions & 0 deletions external_plugins/163-mail/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 163 Mail Assistant (`163-mail`)

> **Disclaimer:** Unofficial community plugin for NetEase Mail, not affiliated with or endorsed by NetEase, Inc. All product names and trademarks belong to their respective owners.

A zero-dependency ZCode plugin that gives AI agents safe, reliable access to NetEase mailboxes — personal mail (163.com / 126.com / yeah.net / 188.com / vip.163.com / vip.126.com) and NetEase enterprise mail (`qiye.163.com`, `ym.163.com`, custom hosts) — over IMAP/SMTP with an MCP server plus an agent skill.

## Highlights

- **Zero runtime dependencies.** Pure Node.js (>= 20) standard library. No `npm install`, no Python environment.
- **NetEase protocol hardened.** RFC 2971 `IMAP ID` after login (avoids `Unsafe Login`), Modified UTF-7 Chinese folder names, GB18030/Big5 charset recovery, `MOVE` with `COPYUID`-verified `UIDPLUS` fallback (never unscoped `EXPUNGE`), SMTP 465 with 25+STARTTLS fallback, Sent-folder deduplication.
- **Chinese-safe search.** Server-side date/flag filtering plus client-side NFKC/case-insensitive header filtering, optional bounded body scan, and `next_before_uid` pagination — NetEase's IMAP `SEARCH` ignores keywords.
- **Verification-code extraction.** Scored OTP extraction (6-digit boost, year/URL filtering) with optional polling wait for newly arriving mail.
- **Two-phase confirmation.** `send_email` and move/trash operations return a preview plus a single-use HMAC-SHA256 token bound to the exact payload (body/attachment hashes); nothing is sent or moved until you confirm.
- **Prompt-injection fencing.** All mail-derived text is wrapped in random-nonce `<<<EMAIL_CONTENT>>>` markers with look-alike markers defused.
- **Attachment safety.** Downloads are sanitized (path traversal, Windows reserved names), never overwrite, are capped at 50 MiB, and get a Windows `Zone.Identifier` mark. Outgoing attachments reject UNC paths, sensitive directories (`.ssh`, `.aws`, `AppData`, …), and cap at 20 MiB total.
- **Secrets never enter chat.** An ephemeral loopback-only (`127.0.0.1`) browser wizard with CSRF/Origin/CSP checks collects the client authorization code, verifies IMAP+SMTP live, and stores it via Windows DPAPI / macOS Keychain / permission-scoped files.

## Components

| Type | Location | Purpose |
| --- | --- | --- |
| MCP server | `scripts/mcp-server.mjs` (declared in `.mcp.json`) | 12 tools over stdio |
| Skill | `skills/163mail/SKILL.md` | Safe workflow guidance (skill name: `163mail`) |
| CLI | `scripts/cli.mjs` | `setup --web`, `accounts`, `doctor`, `selftest` |

## MCP tools

`list_accounts`, `list_folders`, `search_messages`, `read_message`, `get_thread`, `download_attachment`, `get_verification_code`, `create_draft`, `send_email`, `manage_messages`, `open_setup_wizard`, `selftest`.

## Setup wizard & account management

`open_setup_wizard` starts an ephemeral `127.0.0.1` page and **auto-opens the browser**. The page has two views:

- **Account management**: list configured accounts, add, delete (removes the locally stored credential too), and switch the default account.
- **Add / update account**: per-domain official authorization-code tutorial cards (personal mail via 帮助中心, enterprise mail via 官网) that highlight as you type the email domain; submit performs live IMAP (RFC 2971) + SMTP verification before saving.

## Offline self-check (`selftest`)

No account? Call `selftest` (tool or `node scripts/cli.mjs selftest`) for a zero-configuration report covering Modified UTF-7, RFC 2047/GB18030 decoding, MIME composition, attachment path safety, HMAC confirmation tokens, prompt-injection fences, verification-code extraction — plus an offline demo pipeline on bundled sample emails (parse → read → extract code → compose reply with quoted thread → two-phase confirmation).

## Configuration

- Environment variables: `NETEASE_MAIL_USER` + `NETEASE_MAIL_AUTH_CODE` (single account), `NETEASE_MAIL_MODE` (`readonly` | `draft` | `full`, default `draft`), `NETEASE_MAIL_CONFIG`, `NETEASE_MAIL_DOWNLOAD_DIR`, `NETEASE_MAIL_ATTACHMENT_ROOTS`, and per-account `NETEASE_MAIL_AUTH_CODE__<UPPER_UNDERSCORED_EMAIL>`.
- Config file (no secrets stored): `%APPDATA%\netease-mail-assistant\config.json` (Windows) or `~/.config/netease-mail-assistant/config.json`.
- Credentials: Windows DPAPI-encrypted store / macOS Keychain (`security`) / `0600` permission-scoped secrets file; loaded via `keyring`-free local code only.

## Side effects (disclosure)

- **Network access:** connects to NetEase IMAP/SMTP hosts over TLS (993/465, optional 25+STARTTLS) with your credentials; no third-party service receives your mail or credentials.
- **File writes:** attachment downloads go under `~/.netease-mail-assistant/downloads` (override via `NETEASE_MAIL_DOWNLOAD_DIR`); config/secrets are written under the user config directory with restrictive permissions.
- **Command execution:** on Windows the DPAPI helpers invoke `powershell.exe` locally for encryption only; on macOS `/usr/bin/security` is used for Keychain storage.
- **No telemetry, no obfuscated code, no bundled binaries.**
- **UI styling:** the local setup page uses a warm white + honey-gold palette derived from the custom mailbox icon (`assets/icon.png` / `assets/icon.svg`), implemented in inline CSS with zero third-party runtime code or automatic external requests.

## Example Prompts

- `Check if I have any unread emails in my 163 mailbox today and summarize the key points`
- `Grab the login verification code that just arrived in my inbox`
- `Reply to Zhang Wei's statement email and save a draft saying I'll send the confirmation letter tomorrow`
- `Send an email to work@example.com from my 163 mailbox and attach the quote file on my Desktop`
- `Switch my email account and open the account manager`

## Quick start

1. Install the plugin from your marketplace, then ask the agent: *"Open the NetEase Mail setup wizard"* (or run `node scripts/cli.mjs setup --web`); the local setup page opens automatically in your browser.
2. Follow the built-in official tutorial links to create a client authorization code, enter your email and code, and save (IMAP + SMTP are verified live before encrypted local storage).
3. You can also run *"Run 163-mail offline selftest"* without any account to confirm everything works.

## Development

```bash
node --test tests/plugin.test.mjs # 50 unit + stdio e2e tests
node scripts/cli.mjs selftest # zero-config offline self-check & demo (22 checks)
node scripts/cli.mjs doctor # live IMAP/SMTP connectivity check
```

License: MIT. See `specs.md` for the full design specification.
77 changes: 77 additions & 0 deletions external_plugins/163-mail/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 网易邮箱助手(`163-mail`)

> **免责声明**:本插件为社区开源第三方助手工具,**非网易官方出品**,与网易公司无隶属、合作或背书关系;相关商标归各自权利人所有。

一个零外部依赖的 ZCode 插件,通过 MCP Server + Agent Skill 让 AI 智能体安全、稳定地访问网易邮箱——支持个人邮(163.com / 126.com / yeah.net / 188.com / vip.163.com / vip.126.com)与网易企业邮(`qiye.163.com`、`ym.163.com` 及自定义主机)。

## 核心特性

- **零运行时依赖**:纯 Node.js(>= 20)标准库实现,无需 `npm install`,无需 Python 环境。
- **网易协议深度适配**:登录后立即发送 RFC 2971 `IMAP ID`(避免 `Unsafe Login`)、Modified UTF-7 中文文件夹、GB18030/Big5 字符集容错恢复、`MOVE` 优先且 `UIDPLUS` 回退时校验 `COPYUID`(绝不调用无范围 `EXPUNGE`)、SMTP 465 优先并支持 25+STARTTLS 降级、已发送去重保存。
- **中文友好搜索**:服务端只筛日期/已读/星标,客户端做 NFKC + 大小写无关过滤(网易 IMAP 的 `SEARCH` 关键字不可用),支持有界正文扫描与 `next_before_uid` 游标翻页。
- **验证码提取**:加权评分算法(6 位数字加分、年份/URL 过滤),支持 `wait_seconds` 轮询等待新邮件到达。
- **两阶段确认**:`send_email` 与移动/移入回收站操作先返回预览和一次性 HMAC-SHA256 令牌(绑定正文与附件哈希),用户确认后携带原参数重发才会执行。
- **防 Prompt 注入**:所有来自邮件的文本均包裹随机 nonce 的 `<<<EMAIL_CONTENT>>>` 围栏,伪造的同名边界标记会被转义。
- **附件安全**:下载附件清洗文件名(防路径穿越、Windows 保留名)、绝不覆盖、单文件上限 50 MiB、自动写入 Windows `Zone.Identifier` 标记;外发附件拒绝 UNC 路径与敏感目录(`.ssh`、`.aws`、`AppData` 等),总大小上限 20 MiB。
- **授权码绝不进入对话**:本地 `127.0.0.1` 一次性浏览器配置向导(防 CSRF/Origin/CSP),提交时真连 IMAP+SMTP 校验,凭证经 Windows DPAPI / macOS Keychain / 受限权限文件加密保存。

## 组件

| 类型 | 位置 | 用途 |
| --- | --- | --- |
| MCP Server | `scripts/mcp-server.mjs`(声明于 `.mcp.json`) | 12 个工具(stdio) |
| Skill | `skills/163mail/SKILL.md` | 安全工作流指引(技能名:`163mail`) |
| CLI | `scripts/cli.mjs` | `setup --web`、`accounts`、`doctor`、`selftest` |

## MCP 工具清单

`list_accounts`、`list_folders`、`search_messages`、`read_message`、`get_thread`、`download_attachment`、`get_verification_code`、`create_draft`、`send_email`、`manage_messages`、`open_setup_wizard`、`selftest`。

## 配置向导与账号管理

`open_setup_wizard` 启动本机 `127.0.0.1` 一次性页面并**自动打开浏览器**。页面含两个视图:

- **账号管理**:列出已配置账号,可新增、删除(同时清除本机授权码)、切换默认账号。
- **新增 / 更新账号**:按域名自动高亮的官方授权码教程卡片(个人邮 → 帮助中心,企业邮 → 官网),提交时真连 IMAP(RFC 2971)+ SMTP 验证后才保存。

## 离线自检(`selftest`)

没有账号也能确认插件正常:调用 `selftest` 工具(或 `node scripts/cli.mjs selftest`),零配置输出协议解析(Modified UTF-7、RFC 2047/GB18030)、MIME 组包、附件路径安全、HMAC 确认令牌、防注入围栏、验证码提取的自检报告,并附带内置样例邮件的离线演示全流程(解析 → 读信 → 提验证码 → 组装带引用的回复 → 两阶段确认)。

## 配置方式

- 环境变量:`NETEASE_MAIL_USER` + `NETEASE_MAIL_AUTH_CODE`(单账号)、`NETEASE_MAIL_MODE`(`readonly` / `draft` / `full`,默认 `draft`)、`NETEASE_MAIL_CONFIG`、`NETEASE_MAIL_DOWNLOAD_DIR`、`NETEASE_MAIL_ATTACHMENT_ROOTS`,以及按账号命名的 `NETEASE_MAIL_AUTH_CODE__<大写下划线邮箱>`。
- 配置文件(不存明文授权码):Windows 为 `%APPDATA%\netease-mail-assistant\config.json`,macOS/Linux 为 `~/.config/netease-mail-assistant/config.json`。
- 凭证存储:Windows DPAPI 加密 / macOS Keychain / `0600` 权限受限文件,全部由本插件本地代码实现,不引入第三方依赖。

## 副作用披露

- **网络访问**:使用你的授权码通过 TLS(993/465,可选 25+STARTTLS)直连网易 IMAP/SMTP 服务器;不会把邮件或凭证发送给任何第三方服务。
- **文件写入**:附件下载默认保存到 `~/.netease-mail-assistant/downloads`(可用 `NETEASE_MAIL_DOWNLOAD_DIR` 覆盖);配置与凭证写入用户配置目录并施加严格权限。
- **命令执行**:Windows 上 DPAPI 加密 helper 会在本机调用 `powershell.exe`(仅用于加解密);macOS 上使用 `/usr/bin/security` 操作钥匙串。
- **无遥测、无混淆代码、不捆绑二进制。**
- **界面样式**:本地配置页采用源自原创邮箱图标(`assets/icon.png` / `assets/icon.svg`)的温和白 + 暖蜂蜜金配色,全部原生内联 CSS 实现,运行时零第三方代码或自动外部请求。

## 试试这样用

- `看看我 163 邮箱今天有没有未读邮件,帮我总结重点`
- `帮我取一下刚刚收到的登录验证码`
- `帮我回复张伟那封对账单,先存草稿说明天给他发确认函`
- `用 163 邮箱给 work@example.com 发封邮件,把桌面上的报价单当附件`
- `换个邮箱账号,打开账号管理页`

## 快速开始

1. 从插件市场安装本插件后,对智能体说:*“帮我打开网易邮箱配置向导”*(或手动运行 `node scripts/cli.mjs setup --web`),浏览器会自动弹出本机安全配置页。
2. 按页面内的官方教程获取客户端授权码,填入邮箱与授权码并点击保存(自动实测 IMAP + SMTP 后加密存入本机)。
3. 无需账号也能先对智能体说:*“运行 163-mail 离线自检”* 确认插件正常工作。

## 开发与测试

```bash
node --test tests/plugin.test.mjs # 50 项单元 + stdio 端到端测试
node scripts/cli.mjs selftest # 零配置离线自检与演示(22 项)
node scripts/cli.mjs doctor # IMAP/SMTP 真连体检
```

许可证:MIT。完整设计见 `specs.md`。
Binary file added external_plugins/163-mail/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions external_plugins/163-mail/assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions external_plugins/163-mail/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "163-mail",
"version": "0.3.4",
"private": true,
"type": "module",
"description": "Zero-dependency NetEase Mail MCP server and ZCode plugin",
"license": "MIT",
"engines": {
"node": ">=20.0.0"
},
"scripts": {
"start": "node scripts/mcp-server.mjs",
"setup": "node scripts/cli.mjs setup --web",
"doctor": "node scripts/cli.mjs doctor",
"selftest": "node scripts/cli.mjs selftest",
"test": "node --test tests/plugin.test.mjs"
}
}
Loading