The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,089 other followers

mutt notes

Posted by jpluimers on 2013/06/28

When the webmail doesn’t do what I want, I fall back on mutt on the Linux command line prompt.

It is an immensely strong and stable text based mail client, but – beyond the basics – has a steep learning curve.

In fact it is so stable, that the CVS repository rarely gets commits

So below a few notes that I used to clean up truckloads of mail.

  1. Read Real Programmers: Jump Start: Mutt — by hackers, for hackers. It is a very short introduction with the most powerful.
  2. Read My first mutt : Searching mail (the best article on My first mutt), and My first mutt : mutt overview. They why limit is far more useful than search, and the basic UI concept of mutt.
  3. The mutt documentation has a text based man page.
  4. But there is both a html manual and text manual
    (the devel doc branch has both html manual and text manual too).
  5. A lot of actions in mutt depends on patterns which are based on regular expressions.

For me the most powerful combination of steps is this:

  1. Limit the message view to a search pattern of messages you are looking for
  2. Tag the (groups of) messages you want to operate on
  3. Use the semicolon tag-prefix command to operate only on the tagged messages

A few more details are below.

Moving around: PgUp/PgDn/Start/End

Keys Z/z/=/*; See

The indexer page and patterns

Limit the view to mail from linked in that contains an opening square bracket [

As mutt is a bit picky about escaping special characters (not yet archived at the WayBack machine), you need to prepend the [ not with one, but two or three backslashes as this example shows:

~f linkedin ~s \\[
~f linkedin ~s \\\[

Some users need three backslashes per escape, but for me two work fine.

The above pattern is probably a bit to wide, as it matches [ anywhere in the subject.

I want to match messages coming from that have [number] at the start of the subject, which results in either of these two patterns:

~f ~s ^\\[([A-Za-z0-9\ ]+)\\]
~f ~s ^\\\[([A-Za-z0-9\ ]+)\\\]

The result was about a thousand messages per month, good for a big cleanup (:

This was good for about 100 messages per month:

~f linkedin ~s "^New comment"

Another one was to match this header: User-Agent: Heirloom mailx 12.5 7/5/10:

~h "Heirloom mailx 12.5 7/5/10"

Many more pattern tips are at


[Wayback] The Mutt E-Mail Client – 3. Patterns: Searching, Limiting and Tagging – 3.1. Pattern Modifier All mail clients suck. This one just sucks less. — me, circa 1995

Table 4.4. Pattern modifiers

Pattern modifier Description
~A all messages
~b EXPR messages which contain EXPR in the message body ***)
=b STRING If IMAP is enabled, like ~b but searches for STRING on the server, rather than downloading each message and searching it locally.
~B EXPR messages which contain EXPR in the whole message ***)
=B STRING If IMAP is enabled, like ~B but searches for STRING on the server, rather than downloading each message and searching it locally.
~c EXPR messages carbon-copied to EXPR
%c GROUP messages carbon-copied to any member of GROUP
~C EXPR messages either to: or cc: EXPR
%C GROUP messages either to: or cc: to any member of GROUP
~d [MIN]-[MAX] messages with “date-sent” in a Date range
~D deleted messages
~e EXPR messages which contains EXPR in the “Sender” field
%e GROUP messages which contain a member of GROUP in the “Sender” field
~E expired messages
~F flagged messages
~f EXPR messages originating from EXPR
%f GROUP messages originating from any member of GROUP
~g cryptographically signed messages
~G cryptographically encrypted messages
~h EXPR messages which contain EXPR in the message header ***)
=h STRING If IMAP is enabled, like ~h but searches for STRING on the server, rather than downloading each message and searching it locally; STRING must be of the form “header: substring” (see below).
~H EXPR messages with a spam attribute matching EXPR
~i EXPR messages which match EXPR in the “Message-ID” field
~k messages which contain PGP key material
~L EXPR messages either originated or received by EXPR
%L GROUP message either originated or received by any member of GROUP
~l messages addressed to a known mailing list
~m [MIN]-[MAX] messages in the range MIN to MAX *)
~M EXPR messages which contain a mime Content-Type matching EXPR ***)
~n [MIN]-[MAX] messages with a score in the range MIN to MAX *)
~N new messages
~O old messages
~p messages addressed to you (consults $fromalternates, and local account/hostname information)
~P messages from you (consults $fromalternates, and local account/hostname information)
~Q messages which have been replied to
~r [MIN]-[MAX] messages with “date-received” in a Date range
~R read messages
~s EXPR messages having EXPR in the “Subject” field.
~S superseded messages
~t EXPR messages addressed to EXPR
~T tagged messages
~u messages addressed to a subscribed mailing list
~U unread messages
~v messages part of a collapsed thread.
~V cryptographically verified messages
~x EXPR messages which contain EXPR in the “References” or “In-Reply-To” field
~X [MIN]-[MAX] messages with MIN to MAX attachments *) ***)
~y EXPR messages which contain EXPR in the “X-Label” field
~z [MIN]-[MAX] messages with a size in the range MIN to MAX *) **)
~= duplicated messages (see $duplicate_threads)
~$ unreferenced messages (requires threaded view)
~(PATTERN) messages in threads containing messages matching PATTERN, e.g. all threads containing messages from you: ~(~P)
~<(PATTERN) messages whose immediate parent matches PATTERN, e.g. replies to your messages: ~<(~P)
~>(PATTERN) messages having an immediate child matching PATTERN, e.g. messages you replied to: ~>(~P)


Where EXPR is a regular expression, and GROUP is an address group.

*) The forms “<[MAX]”“>[MIN]”“[MIN]-” and “-[MAX]” are allowed, too.

**) The suffixes “K” and “M” are allowed to specify kilobyte and megabyte respectively.

***) These patterns read each message in, and can therefore be much slower. Over IMAP this will entail downloading each message. They can not be used for message scoring, and it is recommended to avoid using them for index coloring.

Special attention has to be paid when using regular expressions inside of patterns. Specifically, Mutt’s parser for these patterns will strip one level of backslash (“\”), which is normally used for quoting. If it is your intention to use a backslash in the regular expression, you will need to use two backslashes instead (“\\”).

You can force Mutt to treat EXPR as a simple string instead of a regular expression by using = instead of ~ in the pattern name. For example, =b *.* will find all messages that contain the literal string “*.*”. Simple string matches are less powerful than regular expressions but can be considerably faster.

For IMAP folders, string matches =b=B, and =h will be performed on the server instead of by fetching every message. IMAP treats =h specially: it must be of the form “header: substring” and will not partially match header names. The substring part may be omitted if you simply wish to find messages containing a particular header without regard to its value.


One Response to “mutt notes”

  1. […] mutt notes (not yet archived at the WayBack machine) […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: