Under Development
stars

Auto-Discover and List IMAP Mailboxes#

Prerequisites#

  1. NeoMutt configured with at least one IMAP or local Maildir account.

  2. If using mbsync, a working ~/.mbsyncrc.

Use IMAP Subscribed Folders#

If you read mail directly from an IMAP server, NeoMutt can ask the server for its list of subscribed folders.

  1. Enable subscription checking:

set imap_check_subscribed

Expected result: NeoMutt adds all server-subscribed folders to its mailbox list, as if you had run :mailboxes for each one.

Browse and Subscribe on the Server#

  1. Open the folder browser with c then ? (or press y).

  2. Press s on a folder to subscribe, or u to unsubscribe.

  3. Toggle the view to show only subscribed folders with <toggle-subscribed>.

Expected result: the subscription list on the server is updated and NeoMutt reflects the change.

Discover Local Folders from mbsync#

If you use mbsync to sync to a local Maildir, you can generate the :mailboxes command from the directory tree.

  1. Add a command that lists your synced folders:

mailboxes `find ~/.local/share/mail/you@example.com -type d -name cur -printf '%h\n' | sort`

This finds every Maildir folder (each has a cur/ subdirectory) and returns the parent path.

Expected result: all synced folders appear in the mailbox list and sidebar.

Use mbsync’s Channel List#

  1. List the folders a channel knows about:

mbsync -l you@example.com
  1. Use the output in a helper script that generates :mailboxes commands, then source it:

source "~/.config/neomutt/gen-mailboxes.sh|"

Expected result: the mailbox list stays in sync with whatever mbsync knows about.

Add Friendly Names with named-mailboxes#

  1. Replace raw paths with labelled entries:

named-mailboxes "Inbox"   "+INBOX"
named-mailboxes "Sent"    "+Sent"
named-mailboxes "Drafts"  "+Drafts"
named-mailboxes "Trash"   "+Trash"

Expected result: the sidebar and browser show readable names instead of folder paths.

Combine Labels with Scripted Discovery#

  1. Write a script that outputs :named-mailboxes commands:

#!/bin/sh
# gen-mailboxes.sh — output named-mailboxes for each Maildir folder
MAILDIR="$HOME/.local/share/mail/you@example.com"
for dir in "$MAILDIR"/*/cur; do
    folder="$(basename "$(dirname "$dir")")"
    printf 'named-mailboxes "%s" "+%s"\n' "$folder" "$folder"
done
  1. Source it from your config:

source "~/.config/neomutt/gen-mailboxes.sh|"

Expected result: new folders created by mbsync appear automatically with readable names.

Refresh Mailboxes After Sync#

If new folders appear after running mbsync, re-source the mailbox list without restarting NeoMutt:

macro index o "<shell-escape>mbsync -a && notmuch new<Enter><enter-command>source ~/.config/neomutt/gen-mailboxes.sh|<Enter>" "Sync and refresh mailboxes"

Expected result: pressing o syncs mail and updates the mailbox list in one step.

See Configure Mailboxes for the full :mailboxes command reference and Sidebar for display options.