From ca7c075b52c7cacbfa8961197ff249d2c80d7e92 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 15 Oct 2026 17:57:12 +0000 Subject: [PATCH 1/2] Add inbox wait: wait for mail and extract a verification code or link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `mailly inbox wait` (shortcut `mailly wait`) polls the existing GET /inbox/messages list with a since filter until a matching inbound message arrives, then prints it, or with --extract only the one-time code or the verification / magic sign-in link it contains. - Filters: --from (address, domain incl. subdomains, or name part), --subject, --to, --address-id. The server narrows with fuzzy search; exact rules are applied client-side, so lookalike domains never match. - --timeout (default 5m), --since (default now; durations, dates, ISO 8601 or Unix seconds), --interval (default 3s, min 1s). - Text mode prints just the value; --json prints {success, message_id, thread_id, from, to, subject, received_at, code|link}. - Exit codes: 2 on timeout, 3 when matching mail had no code or link. Transient API errors (408/429/5xx/network) back off and keep polling. - Extraction lives in a pure src/extract.ts module: codes prefer 4-8 digit or uppercase alphanumeric tokens near code/OTP/验证码 and skip URLs, order/invoice/phone numbers, amounts and dates; links prefer verify/confirm/sign-in links and skip unsubscribe, tracking, policy and social links. Email content is only read, never acted on. - Docs: README, docs/commands.zh-CN.md, the public skill and its command reference. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01HjPcxjooCvPfcAniZ32im5 --- README.md | 37 +++- docs/commands.zh-CN.md | 16 ++ skills/mailly/SKILL.md | 16 +- skills/mailly/reference/commands.md | 5 + src/commands/inbox.ts | 3 + src/commands/wait.ts | 282 ++++++++++++++++++++++++++++ src/extract.ts | 247 ++++++++++++++++++++++++ src/index.ts | 2 + src/output.ts | 6 +- tests/extract.test.mjs | 154 +++++++++++++++ tests/inbox-wait.test.mjs | 196 +++++++++++++++++++ 11 files changed, 958 insertions(+), 6 deletions(-) create mode 100644 src/commands/wait.ts create mode 100644 src/extract.ts create mode 100644 tests/extract.test.mjs create mode 100644 tests/inbox-wait.test.mjs diff --git a/README.md b/README.md index 448863c..eba8d45 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ In order of precedence: | `login`, `logout`, `whoami` | Sign in with the browser or an API key, and check the current account | | `balance`, `logs` | Usage balance and consumption logs | | `send`, `status` | Send email; multi-recipient sends and campaigns are queued and return a task ID | -| `inbox` | Inbox addresses, threads, message content, replies, attachments, and inbox webhooks | +| `inbox` | Inbox addresses, threads, message content, waiting for verification codes and links, replies, attachments, and inbox webhooks | | `outbox`, `delivery-events`, `webhooks` | Per-recipient sent messages, delivery events, and signed delivery webhooks | | `drafts`, `agents` | Drafts for human review, hosted agent profiles and skills, agent runs, and approving or discarding agent drafts | | `templates`, `workflows`, `events` | Versioned templates and lifecycle workflows triggered by events | @@ -82,9 +82,42 @@ In order of precedence: The full command reference (Chinese) is in [docs/commands.zh-CN.md](docs/commands.zh-CN.md). +## Wait for a verification code + +`mailly inbox wait` (shortcut: `mailly wait`) polls the inbox until a matching message arrives, then prints it, or with `--extract` only the one-time code or verification link inside it: + +```bash +# Prints just the code, e.g. 482913 +mailly inbox wait --from github.com --extract code --timeout 5m + +# Prints the verification or magic sign-in link; unsubscribe, tracking and policy links are skipped +mailly inbox wait --from noreply@example.com --subject "Confirm" --extract link + +# Also accept mail that arrived in the last 10 minutes +mailly inbox wait --from github.com --extract code --since 10m --json +# {"success":true,"message_id":"...","thread_id":"...","from":"noreply@github.com","to":"agent@mailly.site", +# "subject":"Your GitHub launch code","received_at":"2026-10-15T09:30:12.000Z","code":"482913"} +``` + +| Option | Meaning | +|---|---| +| `--from ` | Sender address, domain (subdomains included) or part of the sender name | +| `--subject ` | Subject contains this text (case-insensitive) | +| `--to
`, `--address-id ` | Only mail to this inbox address | +| `--extract code\|link` | Print only the code (4–8 digits, or uppercase letters and digits; separators removed) or the link | +| `--timeout ` | Give up after `30s`, `5m` (default), `1h`, ... | +| `--since