Neomutt Commander
Use when the user wants to read, search, or organise their email inbox, read message content, manage folders, archive messages, or draft a reply or new message — all from the terminal via IMAP. Works with Gmail, Fastmail, Outlook, and any IMAP provider.
If sending is not explicitly enabled or approved by the user, always save outgoing messages as a draft instead of sending.
Prerequisites
Install neomutt and w3m (HTML email renderer):
CODEBLOCK0
Configuration
Create ~/.config/neomutt/neomuttrc (or ~/.neomuttrc):
CODEBLOCK1
For other providers change imap.gmail.com:993 and [Gmail]/Drafts to match your server. For Gmail, imap_pass should be an App Password (Google Account → Security → 2-Step Verification → App Passwords).
Create ~/.config/neomutt/mailcap so w3m renders HTML parts:
CODEBLOCK2
Open neomutt
CODEBLOCK3
Opens the inbox. To open a specific folder directly:
CODEBLOCK4
Navigate the inbox
| Key | Action |
|---|
| INLINECODE6 / INLINECODE7 | Move down / up |
| INLINECODE8 |
Open message |
|
q | Back / quit |
|
? | Full keybinding help |
Search messages
| Key | Pattern | Example |
|---|
| INLINECODE11 | Search visible list by subject/sender | INLINECODE12 |
| INLINECODE13 |
Limit view to a pattern |
l ~f boss@example.com |
|
l . | Clear limit (show all) | |
Search pattern syntax: ~f <from> · ~s <subject> · ~b <body> · INLINECODE19
Read a message
Press Enter on a message. HTML parts render automatically via w3m.
| Key | Action |
|---|
| INLINECODE21 / INLINECODE22 | Page down / up |
| INLINECODE23 |
Toggle headers |
|
v | View MIME attachments |
|
q | Return to index |
Mark as read / unread
| Key | Action |
|---|
| Automatic | Message is marked read when opened |
| INLINECODE26 |
Toggle unread on selected message |
|
t | Tag message; then
;N to mark tagged set |
Archive a message
Move the message out of INBOX into your archive folder:
CODEBLOCK5
On Gmail the archive folder is [Gmail]/All Mail. Add a macro for one-key archiving:
CODEBLOCK6
Manage folders / labels
Folders in IMAP, labels in Gmail — same thing. Move or copy a message:
CODEBLOCK7
Compose a new message
CODEBLOCK8
Fill in To:, Subject:, write body, then:
| Key | Action |
|---|
| INLINECODE32 (in editor) | Finish editing and go to send screen |
| INLINECODE33 |
Send (only if sending is approved) |
|
P |
Postpone — saves to the drafts folder |
|
q | Abort / discard |
Default behaviour: press P to postpone (save draft) unless the user has explicitly asked to send.
Resume a draft
CODEBLOCK9
Open the draft and press e to edit, then y to send or P to re-postpone.
Quit
CODEBLOCK10
Neomutt Commander
当用户想要阅读、搜索或整理电子邮件收件箱、阅读邮件内容、管理文件夹、归档邮件或起草回复/新邮件时使用——全部通过终端IMAP完成。支持Gmail、Fastmail、Outlook以及任何IMAP提供商。
如果未明确启用或经用户批准发送,始终将外发邮件保存为草稿而非发送。
前置条件
安装neomutt和w3m(HTML邮件渲染器):
bash
macOS
brew install neomutt w3m
Ubuntu / Debian
sudo apt install neomutt w3m
配置
创建~/.config/neomutt/neomuttrc(或~/.neomuttrc):
set imap_user = user@gmail.com
set imap_pass = *
set folder = imaps://imap.gmail.com:993
set spoolfile = +INBOX
set sslforcetls = yes
set imap_keepalive = 300
set mail_check = 60
set postponed = +[Gmail]/Drafts
set sort = reverse-date
HTML处理
auto_view text/html
alternative_order text/plain text/html
对于其他提供商,将imap.gmail.com:993和[Gmail]/Drafts替换为对应服务器。对于Gmail,imap_pass应为应用专用密码(Google账户→安全→两步验证→应用专用密码)。
创建~/.config/neomutt/mailcap以便w3m渲染HTML部分:
text/html; w3m -I %{charset} -T text/html; copiousoutput;
打开neomutt
bash
neomutt
打开收件箱。直接打开特定文件夹:
bash
neomutt -f imaps://imap.gmail.com/INBOX
neomutt -f imaps://imap.gmail.com/[Gmail]/All%20Mail # Gmail — 所有邮件
neomutt -f imaps://imap.fastmail.com/INBOX # Fastmail示例
浏览收件箱
打开邮件 |
| q | 返回/退出 |
| ? | 完整按键帮助 |
搜索邮件
| 按键 | 模式 | 示例 |
|---|
| / | 按主题/发件人搜索可见列表 | /invoice |
| l |
按模式限制视图 | l ~f boss@example.com |
| l . | 清除限制(显示全部) | |
搜索模式语法:~f <发件人> · ~s <主题> · ~b <正文> · ~d <日期>
阅读邮件
在邮件上按Enter。HTML部分通过w3m自动渲染。
切换显示邮件头 |
| v | 查看MIME附件 |
| q | 返回索引 |
标记为已读/未读
切换选中邮件的未读状态 |
| t | 标记邮件;然后;N标记已标记集合 |
归档邮件
将邮件移出收件箱到归档文件夹:
s → 输入文件夹名称 → Enter
在Gmail上,归档文件夹为[Gmail]/All Mail。添加一键归档宏:
macro index A =[Gmail]/All Mail Archive
管理文件夹/标签
IMAP中的文件夹,Gmail中的标签——本质相同。移动或复制邮件:
C → 输入文件夹名称 → Enter # 复制(邮件保留在当前文件夹)
s → 输入文件夹名称 → Enter # 移动(从当前文件夹移除)
撰写新邮件
m
填写收件人:、主题:,编写正文,然后:
| 按键 | 操作 |
|---|
| Ctrl-X(在编辑器中) | 完成编辑并进入发送界面 |
| y |
发送(仅当发送已获批准) |
| P |
推迟——保存到草稿文件夹 |
| q | 中止/放弃 |
默认行为:按P推迟(保存草稿),除非用户明确要求发送。
恢复草稿
bash
neomutt -f imaps://imap.gmail.com/[Gmail]/Drafts # Gmail
neomutt -f imaps://imap.fastmail.com/Drafts # Fastmail/通用
打开草稿后按e编辑,然后按y发送或按P重新推迟。
退出
q → 按y确认