imap-smtp-email
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIMAP/SMTP Email Tool
IMAP/SMTP 邮件工具
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.
通过IMAP协议读取、搜索和管理邮件,通过SMTP协议发送邮件。支持Gmail、Outlook、163.com、vip.163.com、126.com、vip.126.com、188.com、vip.188.com以及任何标准IMAP/SMTP服务器。
Configuration
配置说明
Create in the skill folder or set environment variables:
.envbash
undefined在skill目录下创建文件,或设置环境变量:
.envbash
undefinedIMAP Configuration (receiving email)
IMAP Configuration (receiving email)
IMAP_HOST=imap.gmail.com # Server hostname
IMAP_PORT=993 # Server port
IMAP_USER=your@email.com
IMAP_PASS=your_password
IMAP_TLS=true # Use TLS/SSL connection
IMAP_REJECT_UNAUTHORIZED=true # Set to false for self-signed certs
IMAP_MAILBOX=INBOX # Default mailbox
IMAP_HOST=imap.gmail.com # Server hostname
IMAP_PORT=993 # Server port
IMAP_USER=your@email.com
IMAP_PASS=your_password
IMAP_TLS=true # Use TLS/SSL connection
IMAP_REJECT_UNAUTHORIZED=true # Set to false for self-signed certs
IMAP_MAILBOX=INBOX # Default mailbox
SMTP Configuration (sending email)
SMTP Configuration (sending email)
SMTP_HOST=smtp.gmail.com # SMTP server hostname
SMTP_PORT=587 # SMTP port (587 for STARTTLS, 465 for SSL)
SMTP_SECURE=false # true for SSL (465), false for STARTTLS (587)
SMTP_USER=your@gmail.com # Your email address
SMTP_PASS=your_password # Your password or app password
SMTP_FROM=your@gmail.com # Default sender email (optional)
SMTP_REJECT_UNAUTHORIZED=true # Set to false for self-signed certs
undefinedSMTP_HOST=smtp.gmail.com # SMTP server hostname
SMTP_PORT=587 # SMTP port (587 for STARTTLS, 465 for SSL)
SMTP_SECURE=false # true for SSL (465), false for STARTTLS (587)
SMTP_USER=your@gmail.com # Your email address
SMTP_PASS=your_password # Your password or app password
SMTP_FROM=your@gmail.com # Default sender email (optional)
SMTP_REJECT_UNAUTHORIZED=true # Set to false for self-signed certs
undefinedCommon 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 服务器 | 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 Commands (Receiving Email)
IMAP命令(接收邮件)
check
check
Check for new/unread emails.
bash
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]Options:
- : Max results (default: 10)
--limit <n> - : Mailbox to check (default: INBOX)
--mailbox <name> - : Only show emails from last X time (e.g., 30m, 2h, 7d)
--recent <time>
检查新邮件/未读邮件。
bash
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]选项说明:
- :最大结果数(默认:10)
--limit <n> - :要检查的邮箱(默认:INBOX)
--mailbox <name> - :仅显示最近X时间内的邮件(例如:30m、2h、7d)
--recent <time>
fetch
fetch
Fetch full email content by UID.
bash
node scripts/imap.js fetch <uid> [--mailbox INBOX]通过UID获取完整邮件内容。
bash
node scripts/imap.js fetch <uid> [--mailbox INBOX]download
download
Download all attachments from an email, or a specific attachment.
bash
node scripts/imap.js download <uid> [--mailbox INBOX] [--dir <path>] [--file <filename>]Options:
- : Mailbox (default: INBOX)
--mailbox <name> - : Output directory (default: current directory)
--dir <path> - : Download only the specified attachment (default: download all)
--file <filename>
下载某封邮件的所有附件,或指定附件。
bash
node scripts/imap.js download <uid> [--mailbox INBOX] [--dir <path>] [--file <filename>]选项说明:
- :目标邮箱(默认:INBOX)
--mailbox <name> - :输出目录(默认:当前目录)
--dir <path> - :仅下载指定附件(默认:下载所有附件)
--file <filename>
search
search
Search emails with filters.
bash
node scripts/imap.js search [options]
Options:
--unseen Only unread messages
--seen Only read messages
--from <email> From address contains
--subject <text> Subject contains
--recent <time> From last X time (e.g., 30m, 2h, 7d)
--since <date> After date (YYYY-MM-DD)
--before <date> Before date (YYYY-MM-DD)
--limit <n> Max results (default: 20)
--mailbox <name> Mailbox to search (default: INBOX)通过筛选条件搜索邮件。
bash
node scripts/imap.js search [options]
Options:
--unseen 仅显示未读邮件
--seen 仅显示已读邮件
--from <email> 发件人地址包含指定内容
--subject <text> 主题包含指定内容
--recent <time> 最近X时间内的邮件(例如:30m、2h、7d)
--since <date> 指定日期之后的邮件(格式:YYYY-MM-DD)
--before <date> 指定日期之前的邮件(格式:YYYY-MM-DD)
--limit <n> 最大结果数(默认:20)
--mailbox <name> 要搜索的邮箱(默认:INBOX)mark-read / mark-unread
mark-read / mark-unread
Mark message(s) as read or unread.
bash
node scripts/imap.js mark-read <uid> [uid2 uid3...]
node scripts/imap.js mark-unread <uid> [uid2 uid3...]将邮件标记为已读或未读。
bash
node scripts/imap.js mark-read <uid> [uid2 uid3...]
node scripts/imap.js mark-unread <uid> [uid2 uid3...]list-mailboxes
list-mailboxes
List all available mailboxes/folders.
bash
node scripts/imap.js list-mailboxes列出所有可用的邮箱/文件夹。
bash
node scripts/imap.js list-mailboxesSMTP Commands (Sending Email)
SMTP命令(发送邮件)
send
send
Send email via SMTP.
bash
node scripts/smtp.js send --to <email> --subject <text> [options]Required:
- : Recipient (comma-separated for multiple)
--to <email> - : Email subject, or
--subject <text>--subject-file <file>
Optional:
- : Plain text body
--body <text> - : Send body as HTML
--html - : Read body from file
--body-file <file> - : Read HTML from file
--html-file <file> - : CC recipients
--cc <email> - : BCC recipients
--bcc <email> - : Attachments (comma-separated)
--attach <file> - : Override default sender
--from <email>
Examples:
bash
undefined通过SMTP发送邮件。
bash
node scripts/smtp.js send --to <email> --subject <text> [options]必填参数:
- :收件人地址(多个收件人用逗号分隔)
--to <email> - :邮件主题,或使用
--subject <text>从文件读取主题--subject-file <file>
可选参数:
- :纯文本邮件正文
--body <text> - :将正文以HTML格式发送
--html - :从文件读取邮件正文
--body-file <file> - :从文件读取HTML内容
--html-file <file> - :抄送收件人
--cc <email> - :密送收件人
--bcc <email> - :附件(多个附件用逗号分隔)
--attach <file> - :覆盖默认发件人地址
--from <email>
示例:
bash
undefinedSimple text email
简单文本邮件
node scripts/smtp.js send --to recipient@example.com --subject "Hello" --body "World"
node scripts/smtp.js send --to recipient@example.com --subject "Hello" --body "World"
HTML email
HTML格式邮件
node scripts/smtp.js send --to recipient@example.com --subject "Newsletter" --html --body "<h1>Welcome</h1>"
node scripts/smtp.js send --to recipient@example.com --subject "Newsletter" --html --body "<h1>Welcome</h1>"
Email with attachment
带附件的邮件
node scripts/smtp.js send --to recipient@example.com --subject "Report" --body "Please find attached" --attach report.pdf
node scripts/smtp.js send --to recipient@example.com --subject "Report" --body "Please find attached" --attach report.pdf
Multiple recipients
多个收件人
node scripts/smtp.js send --to "a@example.com,b@example.com" --cc "c@example.com" --subject "Update" --body "Team update"
undefinednode scripts/smtp.js send --to "a@example.com,b@example.com" --cc "c@example.com" --subject "Update" --body "Team update"
undefinedtest
test
Test SMTP connection by sending a test email to yourself.
bash
node scripts/smtp.js test通过发送测试邮件给自己来验证SMTP连接。
bash
node scripts/smtp.js testDependencies
依赖安装
bash
npm installbash
npm installSecurity Notes
安全注意事项
- Store credentials in (add to
.env).gitignore - For Gmail: use App Password if 2FA is enabled
- For 163.com: use authorization code (授权码), not account password
- 将凭据存储在文件中(需将该文件添加到
.env).gitignore - 对于Gmail:如果开启了双因素认证,请使用应用专用密码
- 对于163.com:使用授权码,而非账户密码
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_TLSsetting to server requirementsSMTP_SECURE - For self-signed certs: set or
IMAP_REJECT_UNAUTHORIZED=falseSMTP_REJECT_UNAUTHORIZED=false
连接超时:
- 确认服务器正常运行且可访问
- 检查服务器地址/端口配置是否正确
认证失败:
- 确认用户名(通常为完整邮箱地址)正确
- 检查密码是否正确
- 对于163.com:使用授权码,而非账户密码
- 对于Gmail:如果开启了双因素认证,请使用应用专用密码
TLS/SSL错误:
- 确保/
IMAP_TLS设置与服务器要求匹配SMTP_SECURE - 对于自签名证书:将或
IMAP_REJECT_UNAUTHORIZED设置为SMTP_REJECT_UNAUTHORIZEDfalse