Refresh Virtual Mailboxes After New Mail#
Prerequisites#
Notmuch virtual mailboxes configured in NeoMutt (see Getting Started with Notmuch Virtual Mailboxes).
A mail sync tool like mbsync delivering new messages to your Maildir.
Update the Notmuch Database#
After syncing new mail, run:
notmuch new
Expected result: Notmuch indexes any new messages and reports the count.
Refresh in NeoMutt#
NeoMutt shows query results at the time the mailbox was opened. To pick up new messages:
Leave and re-enter the virtual mailbox (press c then select it again), or
Use
<sync-mailbox>($ by default) to force a refresh.
Expected result: newly indexed messages appear in the virtual mailbox.
Create a One-Key Sync Macro#
Add a macro that syncs mail, updates the index, and refreshes the mailbox:
macro index o "<shell-escape>mbsync -a && notmuch new<Enter>" "Sync mail and update Notmuch"
Press o in the index.
Expected result: new mail is downloaded, indexed, and the current mailbox is refreshed.
If you don’t use mbsync, replace mbsync -a && with your sync command, or remove it to run only notmuch new.
Why Mailboxes Don’t Update Automatically#
NeoMutt queries the Notmuch database when a virtual mailbox is opened.
It does not re-query continuously in the background.
Running notmuch new updates the database, and re-entering the mailbox (or syncing) picks up the changes.
See Set Up Periodic Mail Sync to automate the sync and index step.