Getting Started with Notmuch Virtual Mailboxes#
In this tutorial you will turn Notmuch search queries into virtual mailboxes inside NeoMutt. Youβll verify your Notmuch database, write a query, add it as a virtual mailbox, and open it. By the end youβll have multiple query-backed views of your mail.
This tutorial assumes your mail is already indexed by Notmuch. If not, complete Setting Up Notmuch for Email Search first.
Check Your Notmuch Setup#
Run a quick search from the command line:
notmuch search tag:inbox
Expected result: a list of message threads.
If the output is empty:
Run
notmuch newto index any new mail.Confirm that the database path in your Notmuch config matches your Maildir location:
notmuch config get database.path
Create Your First Query#
A Notmuch query selects messages by tags, sender, date, or full-text content.
Try a simple query that combines two tags:
notmuch search tag:inbox and tag:unread
tag:inboxβ messages in the inbox.tag:unreadβ messages you havenβt read.andβ both conditions must match.
Expected result: only unread inbox messages are listed.
Add a Virtual Mailbox in NeoMutt#
Add these lines to your
neomuttrc:
set virtual_spool_file = yes
virtual-mailboxes "Unread" "notmuch://?query=tag:inbox and tag:unread"
"Unread"is the label NeoMutt shows in the sidebar and mailbox browser.notmuch://?query=...tells NeoMutt to populate the mailbox from the query result.
Open the Virtual Mailbox#
Start NeoMutt.
Navigate to the mailbox list β use the sidebar, or press c then ? to open the browser.
Select Unread.
Expected result: the index shows only messages that match tag:inbox and tag:unread.
Messages from different physical folders appear together in one unified view.
Add Another Virtual Mailbox#
Append a second entry to your config:
virtual-mailboxes "Flagged" "notmuch://?query=tag:flagged"
Restart NeoMutt or reload the config with
:source.
Expected result: both Unread and Flagged appear in your mailbox list, each showing a different slice of your mail.
What Just Happened#
Notmuch stores your mail in a Maildir and maintains a database of tags alongside it. Each query selects a subset of messages based on those tags (or sender, date, body text, etc.). NeoMutt presents each query result as if it were a regular mailbox β you read, reply, and tag messages the same way you would in any other folder.
The key difference is that virtual mailboxes are dynamic: their contents change as messages are tagged or new mail arrives and is indexed.
Next Steps#
βI want to build more queries.β See Create a Virtual Mailbox for Unread Mail and Combine Multiple Conditions.
βI want to organise my mailbox list.β See Organise Multiple Virtual Mailboxes.
βI want to tag messages as a workflow.β See Organising Email with Tags and Use Tags as a Workflow.
βI want to understand Notmuch query syntax.β See Notmuch.