# NeoMutt Workflows and Usage (Gmail Users Guide)

This guide translates familiar **Gmail web UI concepts** into **NeoMutt workflows**. It covers interface navigation, reading, replying, searching, composing, attaching files, and sending emails directly from the command line.

---

## 1. Key Concepts: Gmail vs. NeoMutt

| Gmail Concept | NeoMutt Equivalent | Explanation / Behavior |
| :--- | :--- | :--- |
| **Labels / Folders** | **Mailboxes / Folders** | Gmail labels map to IMAP folders like `+[Gmail]/All Mail`, `+[Gmail]/Sent Mail`, etc. |
| **Archive (`e` or `y`)** | **Delete / Move (`d` or `s`)** | In Gmail, "archiving" removes the `INBOX` label. In NeoMutt, move (`s`) the message to `+[Gmail]/All Mail`. |
| **Threads / Conversations** | **Threaded View (`sort = threads`)** | NeoMutt displays email chains visually nested as tree structures. |
| **Search Bar (`/`)** | **Search (`/`) & Limit (`l`)** | Search filters current mailbox; Limit filters displayed list to matching patterns. |
| **Starred Messages** | **Flagged Messages (`F`)** | Flagging a message sets the `F` flag, which maps to Gmail Stars. |
| **Drafts** | **Postponed Messages (`P`)** | Saving an unfinished email stores it in `+[Gmail]/Drafts` (Postponed folder). |

---

## 2. Understanding the NeoMutt Interface

The NeoMutt UI is split into key sections:

```text
+------------------+-------------------------------------------------------------+
| Sidebar          | Index View (Email List)                                     |
|                  |                                                             |
| N 1 Inbox (12)   |  1 N  Jan 12 Alice Smith     (1.2K) Meeting Notes           |
|   2 Sent         |  2    Jan 11 Bob Johnson     (4.5K) Re: Project Update     |
|   3 Drafts (1)   |  3 F  Jan 10 Server Alerts   (10K)  [URGENT] High Load     |
|   4 All Mail     |                                                             |
+------------------+-------------------------------------------------------------+
| Status Bar       | -- NeoMutt: Inbox [Msgs:12 New:1 Flagged:1] (threads) ---  |
+------------------+-------------------------------------------------------------+
| Help Line        | q:Quit  d:Del  r:Reply  m:Mail  c:ChangeFolder  /:Search    |
+------------------+-------------------------------------------------------------+
```

### Status Flags in Index View
* `N`: New / Unread email
* `O`: Old (unread, but seen in previous session)
* `r`: Replied to
* `F`: Flagged / Starred
* `D`: Marked for deletion
* `+`: Message is addressed specifically to you

---

## 3. Navigation & Reading Messages

### Moving Between Messages and Folders

* **`j` / `k`** (or `Down` / `Up` arrows): Move to next/previous email in list.
* **`Enter` / `Space`**: Open highlighted email in **Pager view**.
* **`q`**: Exit current view (leave message view back to index, or quit NeoMutt from index).
* **`c`**: Change mailbox (e.g. type `+[Gmail]/Spam` or `=INBOX` and press Enter).
* **Sidebar Controls**:
  * `Ctrl+n`: Move to next folder in sidebar.
  * `Ctrl+p`: Move to previous folder in sidebar.
  * `Ctrl+o`: Open highlighted folder in sidebar.
  * `B`: Toggle sidebar visibility.

### Reading Messages in Pager View

* **`Space`**: Page down / scroll down through email text.
* **`-`**: Page up / scroll up.
* **`J` / `K`**: Jump to next / previous thread.
* **`v`**: View attachments list inside the email.
* **`h`**: Toggle display of raw email headers.

---

## 4. Searching & Filtering Mail

NeoMutt provides powerful search syntax using pattern modifiers:

### Search within Current Mailbox (`/`)
Press `/` and enter a search pattern:

* **`/ Alice`**: Search subject and body for "Alice".
* **`/~f Alice`**: Search messages **From** Alice.
* **`/~s Meeting`**: Search messages with **Subject** containing "Meeting".
* **`/~b "project update"`**: Search message **Body** for phrase.
* **`/~N`**: Search for **New** (unread) messages.
* **`/~F`**: Search for **Flagged** (starred) messages.
* **`/~d <1d`**: Search for messages received in the last 1 day.

Press `n` to jump to the next search match, or `N` to jump to the previous match.

### Filtering (Limiting) the View (`l`)
Press `l` (lowercase L) to hide all emails except those matching a pattern:

* **`l ~N`**: Show *only* unread emails.
* **`l ~f boss@example.com`**: Show *only* emails from boss@example.com.
* **`l all`**: Reset limit (show all emails again).

---

## 5. Replying, Forwarding & Managing Mail

* **`r`**: Reply to sender.
* **`g`**: Group reply (Reply All).
* **`f`**: Forward message.
* **`d`**: Mark message for deletion (purged on exit/folder sync).
* **`u`**: Undelete marked message.
* **`F`**: Flag / Star message.
* **`N`**: Toggle new/read status.
* **`s`**: Save / Move message to another IMAP folder.

---

## 6. Composing & Drafting Emails

### Creating a New Email (`m`)

1. Press `m` in index view.
2. Enter recipient address (`To:`) and press Enter.
3. Enter subject (`Subject:`) and press Enter.
4. NeoMutt opens your configured text editor (e.g. Vim, Nano).
5. Type your email body, save, and exit the editor.

### The Compose Menu

After exiting your editor, you are placed in NeoMutt's **Compose Menu**:

```text
-- NeoMutt: Compose  [To: user@example.com, Subject: Test] -------------------
From: Your Name <your.email@gmail.com>
To: user@example.com
Cc:
Bcc:
Subject: Test
Attachments:
- I     1 /tmp/neomutt-body  [text/plain, 7bit, 0.1K]

y:Send  q:Abort  p:Postpone  e:EditBody  a:AttachFile  t:To  c:Cc  s:Subj
```

* **`y`**: **Send** the email immediately.
* **`a`**: **Attach file** (opens file browser to select file).
* **`p`**: **Postpone** (saves email to Gmail Drafts folder to edit later).
* **`e`**: Re-edit email body in text editor.
* **`t`**: Edit `To:` recipient.
* **`c`**: Add `Cc:` recipient.
* **`b`**: Add `Bcc:` recipient.
* **`s`**: Edit `Subject:`.
* **`q`**: Cancel / Abort composition.

### Resuming Postponed Drafts (`R`)

Press `R` in index view to open the postponed draft list and resume editing.

---

## 7. Command Line Sending & Attachments

NeoMutt can be executed non-interactively directly from the shell or scripts to send emails with attachments.

### Send Simple Email from Terminal
```bash
echo "This is the email body." | neomutt -s "Server Notification" recipient@example.com
```

### Send Email with Attachment (`-a`)
```bash
neomutt -s "Quarterly Report" -a /path/to/report.pdf -- recipient@example.com < /path/to/message.txt
```

> **Note:** The `--` separator is required to denote the end of attachment flags before recipient addresses.

### Send to Multiple Recipients with Attachments
```bash
neomutt -s "Project Backup"   -a /tmp/backup.tar.gz   -a /tmp/logs.txt   -- user1@example.com user2@example.com < /dev/null
```