imap-smtp-email
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIMAP/SMTP Email
IMAP/SMTP Email
Read, search, and manage email via IMAP. Send email via SMTP.
通过IMAP读取、搜索和管理邮件,通过SMTP发送邮件。
Supported Providers
支持的服务商
| 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 |
| 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 |
| 服务商 | 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 |
| 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 |
Configuration
配置
Setup
设置
bash
bash setup.shConfig stored at
~/.config/imap-smtp-email/.envbash
bash setup.sh配置文件存储在
~/.config/imap-smtp-email/.envConfig File Format
配置文件格式
bash
undefinedbash
undefinedDefault account (no prefix)
默认账户(无前缀)
IMAP_HOST=imap.gmail.com
IMAP_PORT=993
IMAP_USER=your@email.com
IMAP_PASS=your_password
IMAP_TLS=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
IMAP_HOST=imap.gmail.com
IMAP_PORT=993
IMAP_USER=your@email.com
IMAP_PASS=your_password
IMAP_TLS=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
File access whitelist
文件访问白名单
ALLOWED_READ_DIRS=/Downloads,/Documents
ALLOWED_WRITE_DIRS=~/Downloads
---ALLOWED_READ_DIRS=/Downloads,/Documents
ALLOWED_WRITE_DIRS=~/Downloads
---Multi-Account Support
多账户支持
Adding an Account
添加账户
bash
undefinedbash
undefinedRun setup and choose "Add a new account"
运行setup并选择"Add a new account"
bash setup.sh
Or manually add prefixed variables:
```bashbash setup.sh
或者手动添加带前缀的变量:
```bashWork account (WORK_ prefix)
工作账户(WORK_前缀)
WORK_IMAP_HOST=imap.company.com
WORK_IMAP_PORT=993
WORK_IMAP_USER=me@company.com
WORK_IMAP_PASS=password
WORK_SMTP_HOST=smtp.company.com
WORK_SMTP_PORT=587
WORK_SMTP_USER=me@company.com
WORK_SMTP_PASS=password
undefinedWORK_IMAP_HOST=imap.company.com
WORK_IMAP_PORT=993
WORK_IMAP_USER=me@company.com
WORK_IMAP_PASS=password
WORK_SMTP_HOST=smtp.company.com
WORK_SMTP_PORT=587
WORK_SMTP_USER=me@company.com
WORK_SMTP_PASS=password
undefinedUsing a Named Account
使用指定账户
bash
undefinedbash
undefinedUse --account <name> before the command
在命令前使用 --account <name>
node scripts/imap.js --account work check
node scripts/smtp.js --account work send --to foo@bar.com --subject Hi --body Hello
---node scripts/imap.js --account work check
node scripts/smtp.js --account work send --to foo@bar.com --subject Hi --body Hello
---IMAP Commands (Receiving Email)
IMAP命令(接收邮件)
check — Check for New Emails
check — 检查新邮件
bash
node scripts/imap.js [--account <name>] check [--limit 10] [--mailbox INBOX] [--recent 2h]Options:
- : Max results (default: 10)
--limit - : Mailbox to check (default: INBOX)
--mailbox - : Only show emails from last X time (e.g., 30m, 2h, 7d)
--recent
bash
node scripts/imap.js [--account <name>] check [--limit 10] [--mailbox INBOX] [--recent 2h]选项:
- : 最大结果数(默认:10)
--limit - : 要检查的邮箱(默认:INBOX)
--mailbox - : 仅显示最近X时间内的邮件(例如:30m、2h、7d)
--recent
fetch — Fetch Full Email
fetch — 获取完整邮件
bash
node scripts/imap.js [--account <name>] fetch <uid> [--mailbox INBOX]bash
node scripts/imap.js [--account <name>] fetch <uid> [--mailbox INBOX]download — Download Attachments
download — 下载附件
bash
node scripts/imap.js [--account <name>] download <uid> [--dir <path>] [--file <filename>]bash
node scripts/imap.js [--account <name>] download <uid> [--dir <path>] [--file <filename>]search — Search Emails
search — 搜索邮件
bash
node scripts/imap.js [--account <name>] search [options]Options:
- : Only unread messages
--unseen - : Only read messages
--seen - : From address contains
--from <email> - : Subject contains
--subject <text> - : From last X time
--recent <time> - : After date (YYYY-MM-DD)
--since <date> - : Before date (YYYY-MM-DD)
--before <date> - : Max results (default: 20)
--limit <n>
bash
node scripts/imap.js [--account <name>] search [options]选项:
- : 仅显示未读邮件
--unseen - : 仅显示已读邮件
--seen - : 发件人地址包含指定内容
--from <email> - : 主题包含指定内容
--subject <text> - : 最近X时间内的邮件
--recent <time> - : 指定日期之后的邮件(格式:YYYY-MM-DD)
--since <date> - : 指定日期之前的邮件(格式:YYYY-MM-DD)
--before <date> - : 最大结果数(默认:20)
--limit <n>
mark-read / mark-unread
mark-read / mark-unread
bash
node scripts/imap.js [--account <name>] mark-read <uid> [uid2 uid3...]
node scripts/imap.js [--account <name>] mark-unread <uid> [uid2 uid3...]bash
node scripts/imap.js [--account <name>] mark-read <uid> [uid2 uid3...]
node scripts/imap.js [--account <name>] mark-unread <uid> [uid2 uid3...]list-mailboxes
list-mailboxes
bash
node scripts/imap.js [--account <name>] list-mailboxesbash
node scripts/imap.js [--account <name>] list-mailboxeslist-accounts
list-accounts
bash
node scripts/imap.js list-accountsbash
node scripts/imap.js list-accountsSMTP Commands (Sending Email)
SMTP命令(发送邮件)
send — Send Email
send — 发送邮件
bash
node scripts/smtp.js [--account <name>] send --to <email> --subject <text> [options]Required:
- : Recipient (comma-separated for multiple)
--to - : Email subject
--subject
Optional:
- : Plain text body
--body - : Send body as HTML
--html - : Read body from file
--body-file - : Read HTML from file
--html-file - : CC recipients
--cc - : BCC recipients
--bcc - : Attachments (comma-separated)
--attach - : Override default sender
--from
Examples:
bash
undefinedbash
node scripts/smtp.js [--account <name>] send --to <email> --subject <text> [options]必填项:
- : 收件人(多个收件人用逗号分隔)
--to - : 邮件主题
--subject
可选项:
- : 纯文本邮件内容
--body - : 将内容以HTML格式发送
--html - : 从文件读取邮件内容
--body-file - : 从文件读取HTML内容
--html-file - : 抄送收件人
--cc - : 密送收件人
--bcc - : 附件(多个附件用逗号分隔)
--attach - : 覆盖默认发件人
--from
示例:
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 SMTP Connection
test — 测试SMTP连接
bash
node scripts/smtp.js [--account <name>] testbash
node scripts/smtp.js [--account <name>] testImportant Notes
重要说明
Gmail
Gmail
- Regular password is rejected
- Must generate an App Password: https://myaccount.google.com/apppasswords
- Requires 2-Step Verification enabled
- 普通密码会被拒绝
- 必须生成 App Password:https://myaccount.google.com/apppasswords
- 需要启用两步验证
163.com / 126.com
163.com / 126.com
- Use authorization code (授权码), not account password
- Enable IMAP/SMTP in web settings first
- 使用 授权码(而非账户密码)
- 需先在网页设置中启用IMAP/SMTP
Dependencies
依赖项
bash
npm installbash
npm installSecurity Notes
安全说明
- Config stored at with 600 permissions
~/.config/imap-smtp-email/.env - File access whitelist limits where attachments can be saved
- Never commit .env files to version control
- 配置文件存储在 ,权限为600
~/.config/imap-smtp-email/.env - 文件访问白名单限制了附件的保存路径
- 切勿将.env文件提交到版本控制系统