---
name: notify
description: Notify the user by email when they are away from the computer — fire at goal completion, goal blockage, before asking the user a decision, and at long-task milestones.
whenToUse: Use whenever the user should be pinged on their phone — a goal finished, a goal is blocked, you are about to ask the user a question, or a long-running task reached a milestone.
---

# notify — Email reminders to the user's phone

Sends an email to the user's phone mailbox so they come back to the computer. One-way ping only — no remote control.

**This skill ships a zero-dependency Node sender (`sender.mjs`, uses only `node:tls`/`node:net`).** Prefer it — DSH runs on Node, so it is available in every normal session. The implementation notes below remain as the fallback for exotic environments where Node cannot be used.

## When to fire (mandatory)

| Moment | Suggested marker |
|---|---|
| A goal completed | `done` |
| A goal is blocked / stuck | `block` |
| You are about to ask the user a decision (fire BEFORE asking) | `question` |
| A long task hit a milestone | `info` |

Also use it for anything else that needs the user's attention while they are away. Do not let the notify call block your main task — fire it and continue working.

## Message content

- Write in the user's language (this user is Chinese).
- Be specific: what finished, why blocked, or what decision is needed, plus anything you expect the user to do when they return.
- Keep it short — it lands on a phone notification.

## Configuration contract

The user's credentials live in `config.json` in this skill's base directory (see `config.example.json`). Never commit it. Fields:

- `email.from` — sender mailbox
- `email.authCode` — SMTP authorization code (**not** the login password)
- `email.to` — recipient (usually the user's own mailbox)
- `email.smtpHost` / `email.smtpPort` / `email.useSsl` — optional; infer when empty:
  - `@qq.com` → `smtp.qq.com`
  - `@163.com` → `smtp.163.com`
  - port 465, implicit TLS

Getting the authorization code — if the user needs it, explain in Chinese:
- **QQ Mail**: 网页版 QQ 邮箱 → 设置 → 账户 → 开启「POP3/SMTP 服务」→ 生成 16 位授权码
- **163 Mail**: 网页版 163 邮箱 → 设置 → POP3/SMTP/IMAP/SMTP → 开启 → 新增授权码

## Check configuration FIRST (mandatory)

Before your first notify call:

1. Read `config.json` in this skill's base directory (create it from `config.example.json` if missing).
2. It must have non-empty `email.from`, `email.authCode`, `email.to`.
3. If missing or incomplete: **do not guess or invent credentials.** Explain the two steps above, ask the user for the sender address, the authorization code, and the recipient, then write `config.json` accordingly. Only proceed once the config is complete.

## Sending the email

**Preferred — bundled sender** (works whenever Node is available):

```bash
node <thisSkillDir>/sender.mjs "subject" "body"
```

or import it from your own code: `import { sendMail } from '<thisSkillDir>/sender.mjs'` (resolves on 250, throws on error). It reads `config.json` next to it and speaks SMTP over implicit TLS on port 465 (QQ/163) with `AUTH LOGIN`.

**Fallback — implement it yourself** only if Node is genuinely unavailable:

- SMTP over implicit TLS on port 465: connect → EHLO → AUTH LOGIN (from + 授权码) → MAIL FROM → RCPT TO → DATA → QUIT.
- If .NET `SmtpClient` is your only option on Windows, note it has a known hang on implicit-TLS 465 — prefer Python `smtplib.SMTP_SSL`, curl, or OpenSSL instead.
- On failure (bad code, network): report the error in the session and continue the main task. Do not retry in a loop. Logging sends to `notify.log` next to the scripts is fine.

## Security

- Never print, paste, or commit the authorization code. `config.json` and `notify.log` are gitignored — never force-include them in a commit. A leaked authorization code lets anyone send mail as the user's mailbox.
- The bundled sender never logs the authorization code.
- This skill works for other agents too (Claude Code, etc.): just point them at this file and the config contract; they can use the bundled sender or implement their own.
