cycleuser-mailpilot 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cycleuser_mailpilot-0.0.1.dist-info/METADATA +209 -0
- cycleuser_mailpilot-0.0.1.dist-info/RECORD +28 -0
- cycleuser_mailpilot-0.0.1.dist-info/WHEEL +5 -0
- cycleuser_mailpilot-0.0.1.dist-info/entry_points.txt +2 -0
- cycleuser_mailpilot-0.0.1.dist-info/licenses/LICENSE +674 -0
- cycleuser_mailpilot-0.0.1.dist-info/top_level.txt +1 -0
- mailpilot/__init__.py +85 -0
- mailpilot/__main__.py +8 -0
- mailpilot/agent/__init__.py +5 -0
- mailpilot/agent/tools.py +299 -0
- mailpilot/api.py +564 -0
- mailpilot/cli/__init__.py +0 -0
- mailpilot/cli/main.py +550 -0
- mailpilot/core/__init__.py +0 -0
- mailpilot/core/_des.py +985 -0
- mailpilot/core/_md4.py +54 -0
- mailpilot/core/auth.py +211 -0
- mailpilot/core/config.py +346 -0
- mailpilot/core/errors.py +59 -0
- mailpilot/mail/__init__.py +0 -0
- mailpilot/mail/imap_client.py +290 -0
- mailpilot/mail/parser.py +317 -0
- mailpilot/mail/pop_client.py +202 -0
- mailpilot/mail/smtp_client.py +177 -0
- mailpilot/mail/store.py +289 -0
- mailpilot/py.typed +0 -0
- mailpilot/serve/__init__.py +0 -0
- mailpilot/serve/server.py +696 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cycleuser-mailpilot
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Pure-Python command-line mail client: send/receive via SMTP/IMAP/POP3, all mainstream auth methods, built-in mail server, and full agent tool API
|
|
5
|
+
Author: MailPilot Contributors
|
|
6
|
+
License-Expression: GPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/cycleuser/MailPilot
|
|
8
|
+
Project-URL: Repository, https://github.com/cycleuser/MailPilot
|
|
9
|
+
Project-URL: Issues, https://github.com/cycleuser/MailPilot/issues
|
|
10
|
+
Keywords: email,smtp,imap,pop3,cli,mail-client,oauth2,cram-md5,ntlm,agent,function-calling
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Communications :: Email
|
|
22
|
+
Classifier: Topic :: Communications :: Email :: Post-Office
|
|
23
|
+
Classifier: Topic :: Communications :: Email :: Email Clients (MUA)
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.3.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-timeout>=2.1.0; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.3.0; extra == "dev"
|
|
33
|
+
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# MailPilot
|
|
37
|
+
|
|
38
|
+
> [English](README_EN.md) | 中文
|
|
39
|
+
|
|
40
|
+
**纯 Python 命令行邮件客户端 —— 收、发、读、搜、标记 —— 内置邮件服务器,并提供完整的智能体(function-calling)API。**
|
|
41
|
+
|
|
42
|
+
GPL-3.0-or-later 许可。零运行时依赖:SMTP、IMAP、POP3 客户端,asyncio 实现的 SMTP+POP3 服务器,SQLite 本地存储,MIME 解析,以及 NTLM 所需的 DES/MD4 等全部 SASL 认证,均基于 Python 标准库自行实现。
|
|
43
|
+
|
|
44
|
+
## 功能特性
|
|
45
|
+
|
|
46
|
+
- **全部主流协议**:SMTP(发送)、IMAP4(收取/搜索/标志/文件夹)、POP3(收取)——全面支持 SSL 与 STARTTLS。
|
|
47
|
+
- **全部主流认证方式**:SASL `PLAIN`、`LOGIN`、`CRAM-MD5`、`XOAUTH2`/`OAUTHBEARER`、`NTLM`(内置纯 Python DES + MD4),以及 POP3 的 `APOP`。`auto` 模式按服务器通告自动选择。
|
|
48
|
+
- **服务商预设**:gmail、outlook、qq、163、126、yahoo、icloud、zoho、aliyun、sina——一个参数填好全部服务器与端口。
|
|
49
|
+
- **内置邮件服务器**:没配服务器?`mailpilot serve` 即可启动本地 SMTP + POP3 服务器(asyncio、零系统依赖),支持按邮箱认证、CRAM-MD5/APOP,并带中继防护。
|
|
50
|
+
- **本地 SQLite 存储**:每封收取/发出的邮件都可离线搜索、标记、移动、删除。
|
|
51
|
+
- **MIME 处理完善**:multipart/alternative、RFC 2047 中文头、附件(列出 + 保存)、HTML→纯文本兜底。
|
|
52
|
+
- **智能体 API**:每个操作都有对应的 OpenAI function-calling `TOOLS` schema + `dispatch()`,LLM 智能体能像人一样收发、搜索、标记邮件。
|
|
53
|
+
|
|
54
|
+
## 安装
|
|
55
|
+
|
|
56
|
+
要求 Python ≥ 3.10。运行时无任何第三方依赖,全部标准库。
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 推荐:直接装入现有 conda 环境(不需要 venv)
|
|
60
|
+
conda activate dev
|
|
61
|
+
pip install -e .[dev] # [dev] 只额外装 pytest/ruff/mypy
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
只使用 CLI/API 的话,`pip install -e .` 即可。
|
|
65
|
+
|
|
66
|
+
## 数据与文件位置
|
|
67
|
+
|
|
68
|
+
所有运行时数据集中在**一个目录**:默认 `~/.mailpilot/`。
|
|
69
|
+
|
|
70
|
+
| 文件 | 用途 | 权限 |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| `~/.mailpilot/config.json` | 账号凭据(邮箱、授权码/token、服务器地址、端口) | `0600`(保存时强制,仅属主可读写) |
|
|
73
|
+
| `~/.mailpilot/mailpilot.db` | SQLite 存储:每封收取/发出的邮件——原始 RFC822 报文、解析后的头/正文、标志、附件 | `0600`(首次运行后收紧) |
|
|
74
|
+
|
|
75
|
+
目录解析优先级(从高到低):
|
|
76
|
+
|
|
77
|
+
1. `config.json` 内的 `data_dir` 字段
|
|
78
|
+
2. 环境变量 `MAILPILOT_DATA_DIR`
|
|
79
|
+
3. 默认 `~/.mailpilot/`
|
|
80
|
+
|
|
81
|
+
邮件数据库同时保存**完整原始报文**与解析后的字段(主题、发收件人、日期、标志、text/html 正文),因此可离线搜索,附件可随时重新提取。任何真实凭据或邮件内容都不会出现在代码、测试或文档中。
|
|
82
|
+
|
|
83
|
+
整体迁移(config + 邮件):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
export MAILPILOT_DATA_DIR=/Volumes/SecureUSB/mailpilot
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
或在配置文件里设 `"data_dir": "/path"`。
|
|
90
|
+
|
|
91
|
+
### 配置账号(服务商预设)
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
mailpilot config add qq you@qq.com --password <SMTP授权码> --auth login --provider qq
|
|
95
|
+
mailpilot config test -a qq # 探测 IMAP + POP3 + SMTP 认证
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 收取、列览、阅读、搜索、标记
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
mailpilot fetch -a qq -n 20 # 拉取新邮件进本地库
|
|
102
|
+
mailpilot list --unread # 按时间倒序
|
|
103
|
+
mailpilot search "关键词"
|
|
104
|
+
mailpilot read 42 # 头部 + 正文
|
|
105
|
+
mailpilot read 42 --save-attachments ./att
|
|
106
|
+
mailpilot mark 42 --flags seen,flagged
|
|
107
|
+
mailpilot folders
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 发送
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
mailpilot send -t bob@example.com -s "你好" -m "正文" \
|
|
114
|
+
--attach ./report.pdf:report-2026.pdf
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 运行内置服务器
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# 无认证模式,localhost,存入 ~/.mailpilot/mailpilot.db
|
|
121
|
+
mailpilot serve --smtp-port 2525 --pop-port 1110 --domain localhost
|
|
122
|
+
|
|
123
|
+
# 带认证的邮箱(--user 可重复)
|
|
124
|
+
mailpilot serve --user alice@localhost:secret1 --user bob@localhost:secret2
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
随后任何 SMTP/POP3 客户端都可连 `127.0.0.1:2525` / `127.0.0.1:1110`。本地域投递无需认证;向其他域中继需要认证,否则拒绝(550)。
|
|
128
|
+
|
|
129
|
+
### 脚本化 JSON 输出
|
|
130
|
+
|
|
131
|
+
所有命令都接受 `--json`,统一返回 `{"success", "data", "error", "metadata"}`:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
mailpilot list --json --unread | jq '.data[0].subject'
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## 智能体集成(OpenAI Function Calling)
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from mailpilot.agent.tools import TOOLS, dispatch
|
|
141
|
+
|
|
142
|
+
# 1. 把 TOOLS 加进模型的工具列表。
|
|
143
|
+
# 2. 模型发起工具调用时路由:
|
|
144
|
+
result = dispatch("mailpilot_send", {
|
|
145
|
+
"to": ["bob@example.com"],
|
|
146
|
+
"subject": "智能体发来的问候",
|
|
147
|
+
"body": "通过 mailpilot 工具调用发送。",
|
|
148
|
+
})
|
|
149
|
+
print(result) # {"success": True, "data": {...}, "error": None, "metadata": {...}}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
可用工具:`mailpilot_send`、`mailpilot_list`、`mailpilot_read`、`mailpilot_search`、`mailpilot_mark`、`mailpilot_delete`、`mailpilot_move`、`mailpilot_fetch`、`mailpilot_folders`、`mailpilot_account_add`、`mailpilot_account_list`、`mailpilot_account_test`。
|
|
153
|
+
|
|
154
|
+
查看 schema:`mailpilot api --schema`。
|
|
155
|
+
|
|
156
|
+
## Python API
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from mailpilot import ToolResult, send_mail, list_messages, read_message, search_messages, mark_messages
|
|
160
|
+
|
|
161
|
+
result = send_mail(to=["bob@example.com"], subject="Hi", body="Hello")
|
|
162
|
+
if result.success:
|
|
163
|
+
print(result.data["message_id"])
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
所有 API 函数返回 `ToolResult` dataclass(`success`、`data`、`error`、`metadata`、`.to_dict()`、`__bool__` 真值判断)。
|
|
167
|
+
|
|
168
|
+
## 配置
|
|
169
|
+
|
|
170
|
+
账号存于 `~/.mailpilot/config.json`(0600)。完整布局与迁移方法见上文**数据与文件位置**。运行期覆盖:
|
|
171
|
+
|
|
172
|
+
- `MAILPILOT_DATA_DIR` — 数据目录
|
|
173
|
+
- `mailpilot serve --db <path>` — 内置服务器的自定义数据库路径
|
|
174
|
+
|
|
175
|
+
## 项目结构
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
mailpilot/
|
|
179
|
+
├── core/ # config(账号/预设)、errors(ToolResult)、
|
|
180
|
+
│ # auth(PLAIN/LOGIN/CRAM-MD5/XOAUTH2/NTLM/APOP)、
|
|
181
|
+
│ # _des + _md4(NTLM 所需纯 Python 密码学原语)
|
|
182
|
+
├── mail/ # smtp_client、imap_client、pop_client、
|
|
183
|
+
│ # parser(MIME 构建/解析/渲染)、store(SQLite)
|
|
184
|
+
├── serve/ # 内置 asyncio SMTP + POP3 服务器
|
|
185
|
+
├── agent/ # OpenAI function-calling TOOLS + dispatch
|
|
186
|
+
└── cli/ # argparse CLI(config/send/fetch/list/read/search/…)
|
|
187
|
+
tests/ # pytest 套件,含客户端↔内置服务器端到端回环
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## 开发
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
conda activate dev # 用现有环境,无需 venv
|
|
194
|
+
pip install -e .[dev]
|
|
195
|
+
pytest # 59 个测试
|
|
196
|
+
ruff check . && ruff format .
|
|
197
|
+
mypy mailpilot
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## 备注
|
|
201
|
+
|
|
202
|
+
- QQ/163/126 邮箱使用"授权码"而非登录密码——通过 `--password` 传入。凭据**只**存于 `~/.mailpilot/config.json`(0600),绝不落入代码、测试或文档。
|
|
203
|
+
- XOAUTH2 token 可用 `mailpilot config test -a acct --oauth2-token <token>` 或 `Account.oauth2_token` 提供(Gmail/Outlook OAuth 流程)。
|
|
204
|
+
- 内置服务器把投递的邮件存进同一个 SQLite 库,因此 `mailpilot fetch --protocol pop3` 可以对它完整回环——测试智能体时不必碰真实邮箱。
|
|
205
|
+
- 开发直接使用 conda 环境(如 `conda activate dev && pip install -e .[dev]`)——无需 virtualenv。
|
|
206
|
+
|
|
207
|
+
## 许可
|
|
208
|
+
|
|
209
|
+
GPL-3.0-or-later(见 [LICENSE](LICENSE))。
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
cycleuser_mailpilot-0.0.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
2
|
+
mailpilot/__init__.py,sha256=By63_BvN0dafAzBrso1_MdMUAaSjDlfpf_MSeam0Xqw,2125
|
|
3
|
+
mailpilot/__main__.py,sha256=uVZV331bKlXfnNVldFeEEkTvijvwWFK6GJivFCrCoAI,144
|
|
4
|
+
mailpilot/api.py,sha256=NOkL5hmYhiVhNMRK7X0mM7-sLN8zF6LQBqOnn0YZwTM,19325
|
|
5
|
+
mailpilot/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
mailpilot/agent/__init__.py,sha256=fSoTGzl53qS8lOFUFSyb-pwSi_yj5SgQJaDRwFwpx-A,181
|
|
7
|
+
mailpilot/agent/tools.py,sha256=vEtZ8wn3z3x4kQA3gK8SIHVl4MkqpE7Pab0uvxqx5Yk,10711
|
|
8
|
+
mailpilot/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
mailpilot/cli/main.py,sha256=IuJhObaSawr9pctBnsm78Vn6b2FCCwGKDPVxe934jSM,19715
|
|
10
|
+
mailpilot/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
mailpilot/core/_des.py,sha256=NG8u_8wrIs_CcHWTEtz3IUbkZZursrsjHuo1ycIR5eI,12261
|
|
12
|
+
mailpilot/core/_md4.py,sha256=7Bwsn8irUzmtfquvQQ_EaprDRSVifHA91m8OZHQdpBg,1911
|
|
13
|
+
mailpilot/core/auth.py,sha256=ans2BAIIyiLwc8j7j5lUHB5nJoMTthlIvV7X5HnTxZ4,6724
|
|
14
|
+
mailpilot/core/config.py,sha256=H_qxzNqDMynzzOQzZpCDdOagtm2C2Kij7cJfOs-qKes,10468
|
|
15
|
+
mailpilot/core/errors.py,sha256=nqQat6utgQFk6xnbQxyzXBxqR3cuVWA8HHd_EMJ02sc,1470
|
|
16
|
+
mailpilot/mail/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
mailpilot/mail/imap_client.py,sha256=vI-TuoIEZzPQueEiv_BBcbS4m3UJEBi0qvxceBsjtk0,10115
|
|
18
|
+
mailpilot/mail/parser.py,sha256=S43lqIes01C4W_HfVvhRlSUiIlLDO5ukxu38jC1u90s,9878
|
|
19
|
+
mailpilot/mail/pop_client.py,sha256=n-AUnvErhbFSRGuI1Rfem5HMqoIYeAwf126IF84UFGg,6726
|
|
20
|
+
mailpilot/mail/smtp_client.py,sha256=DKJQMdYG6Nm3tJF3ZbCv6O6a9e4He3X9znMT9fW13L8,5897
|
|
21
|
+
mailpilot/mail/store.py,sha256=HtGEjes5X_uQRM_rePE5S72mMwJLpDriPrR3nsyoFxI,10982
|
|
22
|
+
mailpilot/serve/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
+
mailpilot/serve/server.py,sha256=llTeBZK7uQ06Q_zwuFlhfpgY_jJugtEaFtXbIyR-3Og,24810
|
|
24
|
+
cycleuser_mailpilot-0.0.1.dist-info/METADATA,sha256=Ipi9LQ9kY6GFZB10FOYy7TnLpB3ZQfC5fFYho0h1jYE,8771
|
|
25
|
+
cycleuser_mailpilot-0.0.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
26
|
+
cycleuser_mailpilot-0.0.1.dist-info/entry_points.txt,sha256=8auzQ1DJQD2KVYBT4mISjyknUK4_SUpVOq2mzEFwPI0,54
|
|
27
|
+
cycleuser_mailpilot-0.0.1.dist-info/top_level.txt,sha256=GUfVvmHwbbE9-4XRqY6X5FAWwoMfhHDoLlQHA6Z5-xo,10
|
|
28
|
+
cycleuser_mailpilot-0.0.1.dist-info/RECORD,,
|