commit ece0dd557993b4f7134e955e8b045119c5e511d1 Author: zlei9 Date: Sun Mar 29 09:45:51 2026 +0800 Initial commit with translated description diff --git a/SKILL.md b/SKILL.md new file mode 100644 index 0000000..978568a --- /dev/null +++ b/SKILL.md @@ -0,0 +1,274 @@ +--- +name: imap-smtp-email +description: "通过IMAP/SMTP阅读和发送邮件。检查新/未读消息、获取内容、搜索邮箱、标记已读/未读,并发送带附件的邮件。" +metadata: + openclaw: + emoji: "📧" + requires: + bins: + - node + - npm +--- + +# IMAP/SMTP Email Tool + +Read, search, and manage email via IMAP protocol. Send email via SMTP. Supports Gmail, Outlook, 163.com, vip.163.com, 126.com, vip.126.com, 188.com, vip.188.com, and any standard IMAP/SMTP server. + +## Configuration + +Run the setup script to configure your email account: + +```bash +bash setup.sh +``` + +Configuration is stored at `~/.config/imap-smtp-email/.env` (survives skill updates). If no config is found there, the skill falls back to a `.env` file in the skill directory (for backward compatibility). + +### Config file format + +```bash +# Default account (no prefix) +IMAP_HOST=imap.gmail.com +IMAP_PORT=993 +IMAP_USER=your@email.com +IMAP_PASS=your_password +IMAP_TLS=true +IMAP_REJECT_UNAUTHORIZED=true +IMAP_MAILBOX=INBOX + +SMTP_HOST=smtp.gmail.com +SMTP_PORT=587 +SMTP_SECURE=false +SMTP_USER=your@email.com +SMTP_PASS=your_password +SMTP_FROM=your@email.com +SMTP_REJECT_UNAUTHORIZED=true + +# File access whitelist (security) +ALLOWED_READ_DIRS=~/Downloads,~/Documents +ALLOWED_WRITE_DIRS=~/Downloads +``` + +## Multi-Account + +You can configure additional email accounts in the same config file. Each account uses a name prefix (uppercase) on all variables. + +### Adding an account + +Run the setup script and choose "Add a new account": + +```bash +bash setup.sh +``` + +Or manually add prefixed variables to `~/.config/imap-smtp-email/.env`: + +```bash +# Work account (WORK_ prefix) +WORK_IMAP_HOST=imap.company.com +WORK_IMAP_PORT=993 +WORK_IMAP_USER=me@company.com +WORK_IMAP_PASS=password +WORK_IMAP_TLS=true +WORK_IMAP_REJECT_UNAUTHORIZED=true +WORK_IMAP_MAILBOX=INBOX +WORK_SMTP_HOST=smtp.company.com +WORK_SMTP_PORT=587 +WORK_SMTP_SECURE=false +WORK_SMTP_USER=me@company.com +WORK_SMTP_PASS=password +WORK_SMTP_FROM=me@company.com +WORK_SMTP_REJECT_UNAUTHORIZED=true +``` + +### Using a named account + +Add `--account ` before the command: + +```bash +node scripts/imap.js --account work check +node scripts/smtp.js --account work send --to foo@bar.com --subject Hi --body Hello +``` + +Without `--account`, the default (unprefixed) account is used. + +### Account name rules + +- Letters and digits only (e.g., `work`, `163`, `personal2`) +- Case-insensitive: `work` and `WORK` refer to the same account +- The prefix in `.env` is always uppercase (e.g., `WORK_IMAP_HOST`) +- `ALLOWED_READ_DIRS` and `ALLOWED_WRITE_DIRS` are shared across all accounts (always unprefixed) + +## Common Email Servers + +| Provider | IMAP Host | IMAP Port | SMTP Host | SMTP Port | +|----------|-----------|-----------|-----------|-----------| +| 163.com | imap.163.com | 993 | smtp.163.com | 465 | +| vip.163.com | imap.vip.163.com | 993 | smtp.vip.163.com | 465 | +| 126.com | imap.126.com | 993 | smtp.126.com | 465 | +| vip.126.com | imap.vip.126.com | 993 | smtp.vip.126.com | 465 | +| 188.com | imap.188.com | 993 | smtp.188.com | 465 | +| vip.188.com | imap.vip.188.com | 993 | smtp.vip.188.com | 465 | +| yeah.net | imap.yeah.net | 993 | smtp.yeah.net | 465 | +| Gmail | imap.gmail.com | 993 | smtp.gmail.com | 587 | +| Outlook | outlook.office365.com | 993 | smtp.office365.com | 587 | +| QQ Mail | imap.qq.com | 993 | smtp.qq.com | 587 | + +**Important for Gmail:** +- Gmail does **not** accept your regular account password +- You must generate an **App Password**: https://myaccount.google.com/apppasswords +- Use the generated 16-character App Password as `IMAP_PASS` / `SMTP_PASS` +- Requires Google Account with 2-Step Verification enabled + +**Important for 163.com:** +- Use **authorization code** (授权码), not account password +- Enable IMAP/SMTP in web settings first + +## IMAP Commands (Receiving Email) + +### check +Check for new/unread emails. + +```bash +node scripts/imap.js [--account ] check [--limit 10] [--mailbox INBOX] [--recent 2h] +``` + +Options: +- `--limit `: Max results (default: 10) +- `--mailbox `: Mailbox to check (default: INBOX) +- `--recent