[
    {
        "role": "user",
        "content": "in%20maildir%2C%20i%20think%20we%20have%20folders%20and%20within%20each%20folder%2Fmailbox%2C%20we%20have%20new%20cur%20and%20tmp.%20and%20within%20those%2C%20we%20have%20individual%20text%20files%20I%20think%2C%20numbered%20sequentially.%20is%20that%20correct%3F%20when%20is%20new%20cur%20and%20tmp%20used%3F"
    },
    {
        "role": "assistant",
        "content": "Yes, your understanding is mostly correct. A **Maildir** (and its common extension **Maildir++**) is a mail storage format where each folder/mailbox is a directory, and within each folder there are exactly three subdirectories: `tmp`, `new`, and `cur`. Each individual email is stored as a separate file, typically with a unique, sequential-ish name. Here\u2019s a detailed breakdown of how those components work and when each is used:\n\n---\n\n## Maildir Directory Structure\n\nFor a given mailbox or folder (e.g. the Inbox), you\u2019ll see:\n\n- `tmp/`  \n- `new/`  \n- `cur/`  \n\nIf you're using **Maildir++**, there are also subfolders: they\u2019re simply additional Maildir-structured directories, often named with a leading dot (e.g. `.Sent`, `.Archive`) containing their own `tmp`, `new`, `cur` ([doc.dovecot.org](https://doc.dovecot.org/2.3/admin_manual/mailbox_formats/maildir/?utm_source=openai)).\n\n---\n\n## File storage: one message per file\n\n- **Yes**, each email is stored in its own file. The filenames are unique, often using a combination of timestamp, process ID, hostname, inode/device numbers, plus sometimes randomness. This uniqueness avoids collisions and avoids needing locks in many cases. ([courier-mta.org](https://www.courier-mta.org/maildir.html?utm_source=openai))  \n- The names typically don\u2019t follow simple sequential numbering like `1, 2, 3\u2026`, though that might LOOK sequential in small setups. They\u2019re more complex identifiers to avoid clashes. ([en.wikipedia.org](https://en.wikipedia.org/wiki/Maildir?utm_source=openai))\n\n---\n\n## What each subdirectory is for and when they\u2019re used\n\n| Subdirectory | Purpose | When / How It\u2019s Used |\n|---|---|---|\n| **tmp** | Temporary/in-progress deliveries | When a new message is being delivered (by an MTA\u2014Mail Transfer Agent), it\u2019s first created in `tmp`. The idea is to avoid race conditions: If the delivery process crashes or is interrupted, you won\u2019t end up with a partial file in `new` or `cur`. Once writing is complete, the file is moved (typically via `rename()` or link+unlink) from `tmp` to `new` to finalize delivery. ([manpages.org](https://manpages.org/maildir/5?utm_source=openai)) |\n| **new** | Unseen (new/unread) mails | After delivery is fully written (from `tmp`), the file goes into `new`. Mail user agents (MUAs) or IMAP/POP servers will see messages in `new` as \u201cunread/new\u201d for the user. It\u2019s also where clients look first to detect new mail. ([doc.dovecot.org](https://doc.dovecot.org/2.3/admin_manual/mailbox_formats/maildir/?utm_source=openai)) |\n| **cur** | Seen/read (or otherwise acted upon) mails | Once a mail is \u201cseen\u201d or accessed by a client or server (for example, opened, flagged, replied, etc.), it\u2019s moved from `new` to `cur`. During that move, the filename often gets a suffix appended (e.g. `:2,flags`) to encode message status flags\u2014like Seen (S), Replied (R), Flagged, etc. Also, moving with `rename()` ensures the operation is atomic on many file systems. ([en.wikipedia.org](https://en.wikipedia.org/wiki/Maildir?utm_source=openai)) |\n\n---\n\n## Flags and filename suffixes\n\n- When a file is moved into `cur`, it may be renamed to add a *status suffix* of the form `:2,flags`, where `flags` are one or more letters indicating states. For example: `S` for \u201cseen\u201d, `R` for \u201creplied\u201d, `F` for \u201cflagged\u201d, etc. If no flags yet, you might just have `:2,` (no flags). ([courier-mta.org](https://www.courier-mta.org/maildir.html?utm_source=openai))  \n- The `2` in `:2,flags` is a version number in the spec, where version \"2\" is the current official version; \"1\" was experimental. ([en.wikipedia.org](https://en.wikipedia.org/wiki/Maildir?utm_source=openai))\n\n---\n\n## Summary: your bullets confirmed\n\n- Folders/mailboxes are directories \u2014 check.  \n- Within each, you have `tmp`, `new`, `cur` \u2014 check.  \n- Within those, individual text files (one per message) \u2014 check.  \n- Filenames are unique but not necessarily simple sequential numbers \u2014 yes.  \n\n---\n\nIf you want, I can show you some real examples of Maildir paths and filenames or explain how IMAP maps mailbox flags to those suffix flags. Just let me know!"
    }
]