Mutt: An introduction

Mutt is a well-supported mailreader for the UNIX shell, created by Michael Elkins to address some of the common complaints about Elm.

The controls are very similar to those in Elm; if you're familiar with Elm, you should be able to get up to speed on Mutt in no time. There are many customization hooks and features in Mutt, far too numerous to list here. (Among the simplest, you can change the keys for commands to match elm, or pine, or anything else you like.)

If you want more information about it, you might start by looking at the official Mutt website. That page includes many helpful links that will help introduce you to mutt.

Mutt is very friendly to advanced users; however, it's not quite as friendly to beginning UNIX users as Alpine. If you find Mutt a bit daunting and bothersome, we suggest trying Alpine instead.

Like all other UNIX packages on Panix, Mutt has a manpage too. You can reach it by typing man mutt at a UNIX shell prompt.

Using Mutt on Panix

Mutt has very good support for both Maildir and IMAP, which makes it an excellent choice for our mail system. Its one drawback is that there's no support for Pine-style folder collections; the folder browser can be set to your old-style Mail directory or your new Maildir/IMAP folder list, but not both. However, you can easily use the "-f" option to read folders in either place (and in either format).
Your INBOX:

Your INBOX is in maildir format; Mutt can tell this by itself, so you don't need to worry.

If Mutt has trouble seeing the INBOX now, first make sure that your $MAIL environment variable is not set incorrectly. Depending on your previous configurations, it may still be pointing to your old-style ".mailspool" directory. Unset the $MAIL variable and you should be fine.

Is that all?

If you don't want to use IMAP or Webmail, and just want to keep using Mutt the way you always have, you can stop here.

In fact, if your Webmail/IMAP use will just be a matter of peeking in your INBOX occasionally while traveling, you can stop here too. Your INBOX is always visible in Webmail and IMAP.

But, if you want to see your other IMAP folders in Mutt's folder browser or to see your Mutt folders in IMAP and Webmail, it gets more complicated.

Seeing IMAP/Webmail folders in Mutt:

There are three ways to view an IMAP/Webmail folder in Mutt. Here they are:

  1. Tell Mutt the exact folder name

    If you press c to change folders, and then type the exact path of the folder, Mutt will open that folder. This path can either be a UNIX path to the maildir folder, or a URL for the IMAP folder. Folder names are case sensitive.
    So, if you have an IMAP folder called Foo, you would press c, then type either:
    ~/.maildir/.Foo
    or
    imap://localhost/INBOX.Foo
    This method is great if you just need to look in an IMAP folder once in a while.

  2. Set the Mutt "folder" variable for IMAP

    Unless you need to see old-style mail folders in your ~/Mail directory, you can tell Mutt's folder browser to use IMAP instead. This way, when you press c and then ?, Mutt will give you a list of your IMAP folders. Also, you can use the usual equals-sign shorthand to refer to mail folders.

    In your .muttrc file, look for the "folder" variable. Set it this way:
    set folder=imap://localhost/INBOX.
    Don't forget the dot at the end. It's necessary.

    This is also useful if you decide to convert all your old ~/Mail folders into IMAP/Webmail folders (see the next section), and no longer need to look in ~/Mail for them.

  3. Set the Mutt "folder" variable for direct maildir access

    This makes for a messier and harder-to-read folder listing than #2 above, and it will probably load slower with large folders.

    In your .muttrc file, look for the following variables, and change them as follows:
    set folder=$MAIL
    set mask="."
    set mbox_type=Maildir

    Now when you press c and ? to list your folders, you'll see a listing of your .maildir directory. The files beginning with a dot are your folders; feel free to ignore the courierimapuiddb and other such files without dots in front. They're not mail folders.

    You can still use the equals-sign shorthand for folders with this method, but you must remember to include the initial dot in the folder name. So instead of =Foo, you'll need to type =.Foo.

Seeing Mutt folders in IMAP/Webmail:

If you have old-style folders stored in "mbox" format, IMAP (and Webmail) can't read them. All is not lost, though! Panix provides a utility that you can use to convert mbox folders into the IMAP-friendly Maildir format. It's called mb2md (which stands for "mbox to maildir").

The mb2md utility is in /usr/local/bin/, which should be in your $PATH.

Most mail agents, like Mutt, usually save mbox folders in ~/Mail, so we'll use that for our example. Using the example folder named Foo again, here's how you'd convert it so IMAP can read it:
mb2md ~/Mail/Foo ~/.maildir/.Foo
Basically, the syntax is
mb2md (sourcefile) (destination).
Pretty simple. Pay attention to the destination name, though!

To be visible in IMAP and Webmail, a maildir folder must:

Now your "Foo" folder will be useable in IMAP and Webmail. (Though you will have to subscribe to it first.) Voila! Of course, now you'll need to point Mutt at the IMAP folders (see previous section above).

Oh, one last thing... mb2md leaves the source file intact, so don't forget to remove the old mbox folder after you've checked that the new one works. And it merely appends to the destination folder, so if you run it twice with the same parameters you'll get two copies of everything.

The Mutt Sidebar

Most of the installed versions of Mutt have a sidebar feature. Getting this sidebar to work, however, requires a fair bit of configuration.

IMAP or Maildir?

There are two ways of accessing your mail with mutt on Panix - IMAP, or direct maildir access. Most users are doing the latter since that is the default mutt configuration. If you are unsure which you are using, check your muttrc file for a 'set spoolfile' line. If it looks like
set spoolfile="imap://mail.panix.com:144"
then you are using IMAP access.

Configuring the mutt sidebar in a useful way requires 3 things:
Making the sidebar visible
set sidebar_visible=yes
Note: sidebar_visible sets a default value. You can set a key binding for toggling sidebar visibility.

Populating the sidebar with IMAP access
set imap_check_subscribed

Populating the sidebar with maildir access
Add the following code snippet to your muttrc file:
      mailboxes + `\
        cd ~/.maildir ; for file in .?*; do \
          if [ -d "$file" ] ; then \
            echo -n "\"+$file\" "; \
          fi \
        done`
      unmboxes '+..'
    
Note: If you copy and paste this, make sure there are no trailing spaces after the line-end backslashes.

Populating the sidebar with Mbox format mailboxes
Set the folder where your Mboxes are saved:
set folder=[location of mailboxes - typically ~/Mail]

Add the following code snippet to your muttrc file:
    mailboxes + `\
      cd ~/[Mbox location] ; for file in *; do \
        echo -n "\"+$file\" " \
      done`
    unmboxes '+..'
    
Note: If you copy and paste this, make sure there are no trailing spaces after the line-end backslashes.

Keybindings for working with the sidebar

In order to do useful things with the sidebar, such as move around in it, open selected mailboxes, etc., you need to set key bindings. Before doing that, it may be useful to unset certain bindings in your terminal. Adding the following to your shell startup file will free up control keys used for (mostly) obsolete terminal behaviors. (If you actually used these features, don't do this. If you don't know what this is, you're not using it, and you can safely do this.)

stty discard undef # ^o
stty dsusp undef   # ^y
stty stop undef    # ^s
stty start undef   # ^q
      

The syntax for setting a keybinding in your muttrc:
bind index,pager \Cn sidebar-next

Some useful sidebar functions to bind
sidebar-toggle-visible Show or hide the sidebar
sidebar-next Move to the next mailbox in the list
sidebar-prev Move to the previous mailbox in the list
sidebar-open Open the currently selected mailbox
sidebar-next-new Move to the next mailbox with unread or flagged mail
sidebar-prev-new Move to the previous mailbox with unread or flagged mail
sidebar-page-up Show the next pageful of mailboxes. Useful if you havea lot of mailboxes
sidebar-page-down Move the highlight to the next pageful of mailboxes. Useful if you have a lot of mailboxes
sidebar-page-up Move the highlight to the previous pageful of mailboxes

Other resources
www.mutt.org/doc/manual/#sidebar
A sample sidebar configuration>


Last Modified:Monday, 09-May-2022 08:49:32 EDT
© Copyright 2006-2021 Public Access Networks Corporation