Skip to main content

mailmaster

中文

Read, search, send, draft, and manage NetEase MailMaster emails directly from the Windows CLI or Python. Supports both standard IMAP/SMTP accounts and 163/126/yeah.net (Wmsvr) accounts, with Markdown/LaTeX rendering, attachments, drafts, and structured JSON output—no running MailMaster desktop app required.

Installation

Install globally as a CLI tool with uv:

# Recommended: install the global CLI
uv tool install mailmaster

# Optional: render LaTeX math formulas as inline images
uv tool install "mailmaster[latex-image]"

Install as a Python library in a project:

uv add mailmaster
# or
pip install mailmaster

Install from a local checkout or set up a dev environment:

git clone https://github.com/AndersonBY/mailmaster-cli.git
cd mailmaster-cli

# Install your local checkout as a global CLI
uv tool install .

# Or create a local dev environment
uv sync

For AI Agents

mailmaster ships a ready-to-use Agent Skill and consistent JSON output on every command, so AI Agents (Claude Code, Codex, Gemini, Cursor, etc.) can work with email immediately.

Option 1: Load or install the Skill from the CLI

# Print the full Skill playbook directly (for on-the-fly context loading)
mailmaster activate-skill

# Install SKILL.md into the current project or your Agent's global skills folder
mailmaster activate-skill --install project   # .agents/skills/mailmaster/SKILL.md
mailmaster activate-skill --install claude    # ~/.claude/skills/mailmaster/SKILL.md
mailmaster activate-skill --install codex     # ~/.codex/skills/mailmaster/SKILL.md
mailmaster activate-skill --install gemini    # ~/.gemini/config/skills/mailmaster/SKILL.md
mailmaster activate-skill --install cursor    # .cursor/skills/mailmaster/SKILL.md

# Or install to a custom directory / print the bundled SKILL.md path
mailmaster activate-skill --dest C:\path\to\skills
mailmaster activate-skill --path

Option 2: Install from the repository skill/ directory

The repository root contains skill/SKILL.md. Copy skill/ directly into your Agent's skills directory, or install it with a skill manager:

npx skills add AndersonBY/mailmaster-cli

Structured JSON output

Pass --json (or --format json) before or after any subcommand for deterministic JSON output:

mailmaster accounts --json
mailmaster list --account sender@example.com --unread --limit 10 --json

Success envelope:

{"ok": true, "command": "list", "data": {}}

Errors (missing local items, invalid arguments, or server rejections) exit with code 2, print no Python traceback, and include a stable error code and actionable suggestions:

{
  "ok": false,
  "command": "read",
  "error": {"code": "mail_not_found", "message": "...", "details": {}}
}

Common commands

Check status & accounts

# Inspect discovered MailMaster paths and local account count
mailmaster doctor

# List configured accounts (commands accept email, account name, or numeric ID)
mailmaster accounts

# Inspect per-account capabilities and recommended transports
mailmaster capabilities --json
mailmaster capabilities --sendable --mutable --json
mailmaster capabilities --query 163 --json

Read & search locally

Local reads run offline against read-only SQLite snapshots:

# List mailboxes
mailmaster mailboxes --account sender@example.com

# List messages (filter by mailbox, unread status, and limit)
mailmaster list --account sender@example.com --mailbox 收件箱 --limit 10
mailmaster list --account sender@example.com --unread --limit 20

# Read a message (accepts LocalId or RemoteId; pass --html for raw HTML)
mailmaster read --account sender@example.com --mail-id 40073

# Search headers, or add --body to search message bodies as well
mailmaster search --account sender@example.com github --body --limit 5

Send mail (text, HTML, Markdown/LaTeX & attachments)

send-mail automatically selects SMTP or the 163/Wmsvr private transport based on account capabilities (override with --transport smtp|wmsvr-private):

# Plain text
mailmaster send-mail --account sender@example.com `
  --to user@example.com --subject "Weekly update" --body "Progress summary..."

# HTML
mailmaster send-mail --account sender@example.com `
  --to user@example.com --subject "Notice" --html-body "<p>Hello</p>"

# Markdown + LaTeX (supports --markdown-body or --markdown-file)
mailmaster send-mail --account sender@example.com `
  --to user@example.com --subject "Notes" `
  --markdown-body "# Summary`n`nValue: `$E = mc^2$`" --latex-mode auto

# Attachments (supported on both SMTP and 163/Wmsvr)
mailmaster send-mail --account sender@example.com `
  --to user@example.com --subject "Report" --body "See attached." `
  --attach C:\path\report.pdf --attach C:\path\data.xlsx

Use mailmaster smtp-send when you explicitly want SMTP with a custom --from address.

Drafts

Create, update, and send server-side drafts on 163/Wmsvr accounts (with Markdown and attachment support):

# Create a draft (returns draft_id and compose_id)
mailmaster save-draft --account user@163.com `
  --to colleague@example.com --subject "Proposal" `
  --body "First draft" --attach C:\path\spec.pdf

# Update that draft using the returned compose_id
mailmaster save-draft --account user@163.com `
  --subject "Proposal v2" --body "Added section 2" --compose-id <compose_id>

# Send a stored draft by ID or newest matching subject (existing attachments carry over automatically)
mailmaster send-draft --account user@163.com --draft-id <draft_id>
mailmaster send-draft --account user@163.com --subject "Proposal v2"

Mark, move, delete & fetch raw source

Mutations support repeating --mail-id for batch operations. IMAP accounts run over direct IMAP; 163/Wmsvr accounts use the private protocol and verify remote state in the same session:

# Mark read / unread
mailmaster mark-read --account sender@example.com --mail-id 40073
mailmaster mark-unread --account sender@example.com --mail-id 40073 --mail-id 40074

# Move to another mailbox (by folder name or folder ID)
mailmaster move-mail --account sender@example.com --mail-id 40073 --target-mailbox Archive

# Delete messages
mailmaster delete-mail --account sender@example.com --mail-id 40073

# Fetch full RFC822 source to a .eml file (accepts either local numeric ID or RemoteId)
mailmaster fetch-mail --account user@163.com --mail-id 40073 --out message.eml

Python library

from mailmaster import MailMaster

mm = MailMaster()

# List accounts; open by email, account name, or numeric account.id
for account in mm.get_accounts():
    print(account.id, account.email)

acc = mm.open_account("sender@example.com")

# Local reads
for mail in acc.list_mail(limit=5):
    print(mail.local_id, mail.subject)

details = acc.get_details("40073")
print(details.content.text_body)

# Unified send (auto-selects SMTP or 163/Wmsvr; supports Markdown, LaTeX, and attachments)
result = acc.send_mail(
    to=["colleague@example.com"],
    subject="Hello",
    markdown_text="# Hello\n\nSent with `mailmaster`.",
    attachments=[r"C:\path\report.pdf"],
)
print(result["transport"], result["status"])

# Mark read and move
acc.mark_read("40073")
acc.move_mail("40073", target_mailbox="Archive")

See docs/library-api.md for the complete SDK reference (drafts, batch mutations, raw source fetching, errors, skill helpers, and low-level protocol sessions).

Notes

  • Requires Windows with NetEase MailMaster installed and signed in to at least one account (the tool reads its local databases and stored account configs directly—MailMaster does not need to be running).
  • Stored credentials are decrypted in memory at runtime only and are never written back to disk.
  • On 163/Wmsvr accounts, delete-mail performs a permanent server-side delete (it does not move messages to Trash); double-check target IDs before deleting.

Documentation

Development

python -m pytest -q
python -m ruff check .
python -m ty check

License

MIT. See LICENSE.

Metadata

Release files for mailmaster 0.1.0

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

Source distribution (sdist)

Source distribution for mailmaster 0.1.0
File Size Uploaded Provenance Actions
mailmaster-0.1.0.tar.gz 207.0 kB With provenance Details for mailmaster-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mailmaster 0.1.0
File Interpreter ABI Platform Actions
mailmaster-0.1.0-py3-none-any.whl Python 3 none any Details for mailmaster-0.1.0-py3-none-any.whl

Total release size: 344.6 kB

Release files / mailmaster-0.1.0.tar.gz

Download URL mailmaster-0.1.0.tar.gz
Size 207.0 kB
Tags Source
SHA-256 checksum
How to use checksums
40e4ac3f53ae772c7f5de7df4fadbc93395ca484299421128f3180df33bd84e5
BLAKE2b-256 checksum
How to use checksums
6dd8c260802aadeed1448d1d4e08621a7d862034a3a0a4d7b0de2bf09dbc3abf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Release files / mailmaster-0.1.0-py3-none-any.whl

Download URL mailmaster-0.1.0-py3-none-any.whl
Size 137.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
157455e80c28ffb6111e4ac206f32bddc61ee0fb678feb6f849214fb7793a749
BLAKE2b-256 checksum
How to use checksums
bf03a71c2b6a61e0a9347af7d37032b6b6070efc4d4f7596d8eb06678e2a12fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Security for mailmaster 0.1.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mailmaster-0.1.0.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 Nov 24, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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