Searching mail
Pattern matching with regular expressions
Mutt has powerful regular expression matching for searching, tagging mail and limiting the message view - but only within a single mailfolder.
If regular expressions are new to you or just plain scary, don’t panic: mutt will look at your search word and attempt a simple search for you. For example:
In the index view, hit the / key to search all the visible messages. Now, instead of entering a regular expression that you want to match, simply type the word you want to search for: joe , then hit enter. Mutt will translate this into the regular expression: ~f joe | ~s joe. The mutt cursor will jump to the next message with the word joe in the message’s headers From: or Subject:. You can repeat the search and find the next matching message by hitting n for search-next.
All pattern-matches are case-insensitive by default unless you include capital letters in the search string.
Starting a search with the / key is a standard command for searching in many applications, try searching within a message in the pager view.
The limit command
More powerful than the search command is the limit command. In fact, once you start using the limit command, you will probably never need to use search. Instead of pressing / for search , press l for limit , type the word you want to match, joe and hit enter. Mutt will limit the display so that only the matching messages are visible. To return to the full message view, simply limit the view to a word that is guaranteed to match everything: . (a single dot is a simple regular expression that matches any character).
Mutt regular expression extensions
Mutt has some extra features specifically for searching and matching email. You have seen a couple of them already with ~f and ~s in the regular expression above. For a full explanation of all the features, which include matching arbitrary headers, body-text, dates, boolean and/or/not and much more, see the patterns section of the manual.
A few worth knowing straight away:
~d >1w messages newer than a week
~b regexp search the message body
~h regexp search all headers
~x regexp search the References: header
~A everything, for undoing a limit
Searching across multiple mailboxes
A drawback with the Unix Way of storing mail as un-indexed text-files is that mail readers find searching over multiple mailboxes very difficult or slow. Mutt can’t perform a search or limit command over multiple mail folders.
The answer is an external index. You run a program that indexes all of your mail once, it stays up to date incrementally, and searches that would take minutes return instantly. This is by some distance the biggest improvement you can make to a large mail archive, and it is the main practical argument for keeping your mail in a local Maildir rather than reading it over IMAP.
notmuch
notmuch is the tool most people use. It indexes Maildir and MH folders with Xapian, never modifies your mail, and searches with a simple query language:
notmuch search from:joe and date:2026..
The neatest integration is with NeoMutt, which has notmuch support built in - you can open a search result as though it were a mailbox, and tag messages from the index. With plain mutt, use the notmuch-mutt script that ships with notmuch. You bind it to a key yourself - conventionally F8 to search and F9 to reassemble the thread around the current message - and the macros to paste into your muttrc are printed in full in its manpage:
man notmuch-mutt
Pressing the key prompts you for a query and drops you into a temporary Maildir of symlinks to the matching messages.
Whichever you use, the index does not update itself. Run notmuch new after fetching mail, from the same cron job or systemd timer that runs mbsync.
mu
mu is a close relative, also built on Xapian, with a similar query language and a similar way of presenting results as a temporary folder of symlinks. It is best known for its Emacs interface, mu4e, but the command-line tool stands on its own and works with mutt in exactly the same way as notmuch-mutt.
Either is a good choice. Pick notmuch if you are unsure - it is more widely packaged and has more documentation written about it.
mairix
mairix is the lightweight option: a single small C program, no Xapian, no daemon, no tagging. You run mairix to update the index and mairix query to build a folder of results, which you then open in mutt. It handles mbox as well as Maildir and MH, which the others do not.
If notmuch feels like more machinery than you want, this is the one to use.
Older tools
You will still find references to grepmail, mboxgrep and nmzmail. They search by brute force rather than by index, and are variously unmaintained. If your mail is in mbox files and you just want a one-off grep, they still work; for anything you do more than once, index it instead.
Searching on the server
If your mail stays on an IMAP server, mutt can hand some of the work to the server rather than downloading every message to search it. Use the = prefix instead of ~ for a plain string search: =b and =B search the body and the whole message on the server, where ~b and ~B fetch each message and search it locally. On a large remote folder the difference is dramatic, and it is worth using = wherever you already know the exact string you are looking for.
What mutt cannot do, on IMAP or anywhere else, is search across more than one folder. If you need that, synchronise the account to a local Maildir and index it - which is the case where all of this really does pay for itself.
Last updated 31 August 2026.