Skip to main content

qqmail-cli

腾讯企业邮箱 IMAP 命令行客户端,用于浏览邮件、查看正文、下载附件。所有输出均为 JSON 格式。

核心亮点

  • JSON 输出 — 所有命令输出结构化 JSON,默认格式化,--compact 紧凑输出
  • 零配置登录 — .env 文件管理账号密码,一条命令验证连通性
  • 中文文件夹名自动解码 — Modified UTF-7 编码的文件夹名自动解码
  • 纯标准库 IMAP 通信 — 不依赖第三方 IMAP 库

安装

依赖 uv 管理 Python 环境和依赖:

uv sync

安装后可直接使用 qqmail 命令:

qqmail login

也可通过 uv run main.py 执行。

配置

创建 .env 文件,程序会依次从当前工作目录和 ~/.config/qqmail-cli/ 查找并加载(两者都配置时,当前目录优先):

IMAP_HOST=imap.exmail.qq.com
IMAP_PORT=993
IMAP_USER=your_email@example.com
IMAP_PASSWORD=your_password_or_app_token

使用方法

所有命令默认输出格式化 JSON,加 --compact 输出紧凑 JSON。

验证登录

qqmail login

列举邮箱文件夹

qqmail folders

浏览邮件(分页)

# 查看 INBOX 第一页(默认每页 20 封)
qqmail mails

# 指定文件夹和页码
qqmail mails --folder "Sent Messages" --page 2

# 调整每页数量
qqmail mails --size 50

搜索邮件

--since 为必填参数。--from 和 --subject 为可选过滤条件。

# 搜索指定日期以来的邮件
qqmail mails search --since 2026-04-13

# 按发件人过滤
qqmail mails search --since 2026-04-13 --from sender@example.com

# 按主题关键词过滤
qqmail mails search --since 2026-04-13 --subject 周报

# 组合过滤 + 限制数量
qqmail mails search --since 2026-04-13 --before 2026-04-20 \
  --from sender@example.com --subject 周报 --limit 5

查看邮件详情

qqmail mail 1555

# 查看完整内容(含转发的历史邮件)
qqmail mail 1555 --raw

# 指定文件夹
qqmail mail 1555 --folder "Sent Messages"

输出包含:id、from、to、cc、subject、date、body、attachments。

操作附件

# 列出附件
qqmail attachments list 1555

# 下载全部附件
qqmail attachments download 1555 -o /tmp/attachments

# 只下载指定附件
qqmail attachments download 1555 -f "周报.xlsx" -o /tmp/attachments

命令速查

命令 说明
login 验证登录信息
folders 列举邮箱文件夹
mails 浏览邮件(--folder、--page、--size)
mails search 搜索邮件(--since 必填,--from/--subject 可选)
mail <id> 获取邮件详情(--raw 含历史邮件)
attachments list <id> 列出邮件附件
attachments download <id> 下载附件(-f 指定单个,-o 目录)

全局选项:--compact 紧凑 JSON 输出。

许可证

MIT License

Metadata

Release files for qqmail-cli 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qqmail-cli 0.3.1
File Size Uploaded Provenance
qqmail_cli-0.3.1.tar.gz 27.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for qqmail-cli 0.3.1
File Interpreter ABI Platform
qqmail_cli-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 47.7 kB

Release files / qqmail_cli-0.3.1.tar.gz

Download URL qqmail_cli-0.3.1.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6e5eaaf6b6bb354f1d7abccdc0c45116f51c6cbbc834650cfe6394ac1c1843cc
BLAKE2b-256 checksum
How to use checksums
850f8e2f4f27868dbf77c5078be599252d095832c95025dc2ebee7bcf525d7a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 3, 2026.

Transparency log

Release files / qqmail_cli-0.3.1-py3-none-any.whl

Download URL qqmail_cli-0.3.1-py3-none-any.whl
Size 20.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e42fa5952ad33b7fd9603bfec0ca6a28c40fb2b0d3c6fdc1b202671ffb0ab9dc
BLAKE2b-256 checksum
How to use checksums
d1282d1c2f185e840466e25412ee6a3c26da43e94b6643576988e37570d9542b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 3, 2026.

Transparency log

Security for qqmail-cli 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for qqmail_cli-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page