Rules
User wants to view/read/send/mark emails → run the cyeam mail command → return the result.
- View emails: by default use
--allto list all mailboxes, only use<账户> - Read email: must specify
<账户> <uid>, can add--mark-readto also mark as read - Send email: must specify
<账户> - Mark as read/unread: must specify
<账户>and UID, or use--uidsfor batch
用户: "看看我有什么新邮件" → cyeam mail list --all
用户: "看看我 cyeam 邮箱有什么邮件" → cyeam mail list cyeam
用户: "读一下 UID 123 那封" → cyeam mail read cyeam 123
用户: "读一下 UID 123 并标记已读" → cyeam mail read cyeam 123 --mark-read
用户: "把 UID 123 标记为已读" → cyeam mail mark-read cyeam 123
用户: "把 UID 123,456,789 都标记为已读" → cyeam mail mark-read cyeam --uids 123,456,789
用户: "把 cyeam 邮箱所有邮件一键已读" → cyeam mail mark-all-read cyeam
用户: "把 UID 123 标记为未读" → cyeam mail mark-unread cyeam 123
用户: "给 x@y.com 发封邮件" → cyeam mail send cyeam --to x@y.com --subject "..." --body "..."
Reading an email takes two steps: first list --all to get the UID and corresponding account, then read <账户> <uid> to read the body.
Commands
cyeam mail list --all [--limit 20] 列所有邮箱的最近邮件:账户/UID/发件人/主题/时间/未读
cyeam mail list <账户> [--limit 20] 列指定邮箱的最近邮件
cyeam mail read <账户> <uid> [--mark-read] 读单封:发件人/收件人/主题/日期/正文,可选标记已读
cyeam mail mark-read <账户> <uid> 标记单封为已读
cyeam mail mark-read <账户> --uids <uid1,uid2> 批量标记已读,逗号分隔
cyeam mail mark-all-read <账户> 一键标记 INBOX 全部未读邮件为已读
cyeam mail mark-unread <账户> <uid> 标记单封为未读
cyeam mail mark-unread <账户> --uids <uid1,uid2> 批量标记未读
cyeam mail send <账户> --to <地址> --subject <主题> --body <正文>
[--cc <地址>] [--body-file <文件>] 发送邮件(--to/--cc 可重复)
Configuration
The account list is written in ~/.cyeam/mail.json,It is recommended to read both username and password from environment variables, to avoid writing them in plaintext into the config file:
{
"accounts": [
{
"name": "cyeam",
"imap_host": "imap.zoho.com",
"imap_port": 993,
"username_env": "CYEAM_MAIL_USERNAME",
"password_env": "CYEAM_MAIL_PASS",
"smtp_host": "smtp.zoho.com",
"smtp_port": 465
}
]
}
username_env: the name of the environment variable where the username is stored; before running, you needexport CYEAM_MAIL_USERNAME=you@cyeam.comusername: the username written in plaintext in the config (not recommended); if set, it takes priority over username_envpassword_env: the name of the environment variable where the app-specific password is stored; before running, you needexport CYEAM_MAIL_PASS=xxxsmtp_host/smtp_portcan be omitted: by default,imap.is replaced withsmtp., port defaults to 465- For multiple accounts, just add more entries in
accounts, and specify withnamein the command
Common mailbox IMAP/SMTP:
| Mailbox | IMAP | SMTP |
|---|---|---|
| Zoho | imap.zoho.com | smtp.zoho.com |
| Gmail | imap.gmail.com | smtp.gmail.com |
| iCloud | imap.mail.me.com | smtp.mail.me.com |
Prerequisites (user side)
- Enable IMAP access in the mailbox backend
- Generate an "app-specific password" (not the login password) and set it in the corresponding environment variable
- Port 465 uses TLS, 587 uses STARTTLS
Output
All commands output a JSON envelope; add --pretty to remove the envelope.
What it does not do
- Delete or move emails
- Attachment download, full-text search