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
Create .env in the skill folder or set environment variables:
CODEBLOCK0
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 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.
CODEBLOCK1
Options:
- --limit <n>: Max results (default: 10) INLINECODE2 : Mailbox to check (default: INBOX) INLINECODE3 : Only show emails from last X time (e.g., 30m, 2h, 7d)
fetch
Fetch full email content by UID.
CODEBLOCK2
download
Download all attachments from an email, or a specific attachment.
CODEBLOCK3
Options:
- --mailbox <name>: Mailbox (default: INBOX) INLINECODE5 : Output directory (default: current directory) INLINECODE6 : Download only the specified attachment (default: download all)
search
Search emails with filters.
CODEBLOCK4
mark-read / mark-unread
Mark message(s) as read or unread.
CODEBLOCK5
list-mailboxes
List all available mailboxes/folders.
CODEBLOCK6
SMTP Commands (Sending Email)
send
Send email via SMTP.
CODEBLOCK7
Required:
- --to <email>: Recipient (comma-separated for multiple) INLINECODE8 : Email subject, or INLINECODE9
Optional:
- --body <text>: Plain text body INLINECODE11 : Send body as HTML INLINECODE12 : Read body from file INLINECODE13 : Read HTML from file INLINECODE14 : CC recipients INLINECODE15 : BCC recipients INLINECODE16 : Attachments (comma-separated) INLINECODE17 : Override default sender
Examples:
CODEBLOCK8
test
Test SMTP connection by sending a test email to yourself.
CODEBLOCK9
Dependencies
CODEBLOCK10
Security Notes
- Store credentials in .env (add to .gitignore) For Gmail: use App Password if 2FA is enabled For 163.com: use authorization code (授权码), not account password
Troubleshooting
Connection timeout:
- Verify server is running and accessible Check host/port configuration
Authentication failed:
- Verify username (usually full email address) Check password is correct For 163.com: use authorization code, not account password For Gmail: use App Password if 2FA enabled
TLS/SSL errors:
- Match IMAP_TLS/SMTP_SECURE setting to server requirements For self-signed certs: set IMAP_REJECT_UNAUTHORIZED=false or INLINECODE23
IMAP/SMTP 邮件工具
通过IMAP协议读取、搜索和管理电子邮件。通过SMTP发送电子邮件。支持Gmail、Outlook、163.com、vip.163.com、126.com、vip.126.com、188.com、vip.188.com以及任何标准IMAP/SMTP服务器。
配置
在技能文件夹中创建.env文件或设置环境变量:
bash
IMAP配置(接收邮件)
IMAP_HOST=imap.gmail.com # 服务器主机名
IMAP_PORT=993 # 服务器端口
IMAP_USER=your@email.com
IMAP
PASS=your password
IMAP_TLS=true # 使用TLS/SSL连接
IMAP
REJECT UNAUTHORIZED=true # 对于自签名证书设为false
IMAP_MAILBOX=INBOX # 默认邮箱
SMTP配置(发送邮件)
SMTP_HOST=smtp.gmail.com # SMTP服务器主机名
SMTP_PORT=587 # SMTP端口(587用于STARTTLS,465用于SSL)
SMTP_SECURE=false # true用于SSL(465),false用于STARTTLS(587)
SMTP_USER=your@gmail.com # 您的电子邮件地址
SMTP
PASS=your password # 您的密码或应用密码
SMTP_FROM=your@gmail.com # 默认发件人邮箱(可选)
SMTP
REJECT UNAUTHORIZED=true # 对于自签名证书设为false
常见邮件服务器
提供商 IMAP主机 IMAP端口 SMTP主机 SMTP端口 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邮箱 | imap.qq.com | 993 | smtp.qq.com | 587 |
163.com重要提示:
- 使用授权码 ,而非账户密码 先在网页设置中启用IMAP/SMTP
IMAP命令(接收邮件)
check
检查新邮件/未读邮件。
bash
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]
选项:
- --limit :最大结果数(默认:10) --mailbox :要检查的邮箱(默认:INBOX) --recent :仅显示最近X时间内的邮件(例如:30m、2h、7d)
fetch
通过UID获取完整邮件内容。
bash
node scripts/imap.js fetch [--mailbox INBOX]
download
下载邮件的所有附件或指定附件。
bash
node scripts/imap.js download [--mailbox INBOX] [--dir ] [--file ]
选项:
- --mailbox :邮箱(默认:INBOX) --dir :输出目录(默认:当前目录) --file :仅下载指定附件(默认:下载全部)
search
使用筛选条件搜索邮件。
bash
node scripts/imap.js search [options]
选项:
--unseen 仅未读邮件
--seen 仅已读邮件
--from 发件人地址包含
--subject 主题包含
--recent 最近X时间内(例如:30m、2h、7d)
--since 指定日期之后(YYYY-MM-DD)
--before 指定日期之前(YYYY-MM-DD)
--limit 最大结果数(默认:20)
--mailbox 要搜索的邮箱(默认:INBOX)
mark-read / mark-unread
将邮件标记为已读或未读。
bash
node scripts/imap.js mark-read [uid2 uid3...]
node scripts/imap.js mark-unread [uid2 uid3...]
list-mailboxes
列出所有可用的邮箱/文件夹。
bash
node scripts/imap.js list-mailboxes
SMTP命令(发送邮件)
send
通过SMTP发送电子邮件。
bash
node scripts/smtp.js send --to --subject [options]
必需参数:
- --to :收件人(多个收件人用逗号分隔) --subject :邮件主题,或使用--subject-file
可选参数:
- --body :纯文本正文 --html:将正文作为HTML发送 --body-file :从文件读取正文 --html-file :从文件读取HTML --cc :抄送收件人 --bcc :密送收件人 --attach :附件(多个附件用逗号分隔) --from :覆盖默认发件人
示例:
bash
简单文本邮件
node scripts/smtp.js send --to recipient@example.com --subject 你好 --body 世界
HTML邮件
node scripts/smtp.js send --to recipient@example.com --subject 新闻通讯 --html --body
欢迎
带附件的邮件
node scripts/smtp.js send --to recipient@example.com --subject 报告 --body 请查收附件 --attach report.pdf
多个收件人
node scripts/smtp.js send --to a@example.com,b@example.com --cc c@example.com --subject 更新 --body 团队更新
test
通过向自己发送测试邮件来测试SMTP连接。
bash
node scripts/smtp.js test
依赖项
bash
npm install
安全说明
- 将凭据存储在.env文件中(添加到.gitignore) 对于Gmail:如果启用了两步验证,请使用应用密码 对于163.com:使用授权码,而非账户密码
故障排除
连接超时:
认证失败:
- 确认用户名(通常是完整的电子邮件地址) 检查密码是否正确 对于163.com:使用授权码,而非账户密码 对于Gmail:如果启用了两步验证,请使用应用密码
TLS/SSL错误:
- 将IMAPTLS/SMTP SECURE设置与服务器要求匹配 对于自签名证书:设置IMAPREJECT UNAUTHORIZED=false或SMTPREJECT UNAUTHORIZED=false