Skip Navigation

Mail storage

System mailspool and home archives

By default, mutt looks for your inbox mailfolder in the system mailspool. This mailspool is usually an mbox file somewhere like /var/spool/mail/$USER (where $USER is your username). To find out where your mailspool is, type this command in your shell:

echo $MAIL

Your mailspool is just one folder and you should only use it for current mail. Keep old mail archives and filter mailing-lists to mailfolders somewhere in your home directory. By default mutt looks for these folders in the ~/Mail/ directory.

Some people find that it is more logical to have your mailspool in your home directory along with all your other mail. Look at the filtering mail section to find out how to get your system to deliver incoming mail into your home directory.

You can use this configuration command to get mutt to look for your mailspool somewhere other than /var/spool/mail/$USER:

set spoolfile=~/Mail/inbox

Of course your spoolfile doesn't have to be on your local machine, mutt allows you to keep it anywhere, such as a POP3 or IMAP mailbox. It could be mounted via nfs or another network based file system.

Creating mail folders

To create a new mail folder, just move or copy a message and type the name of your folder; mutt will create the folder for you if it doesn't already exist (move/save is the s key and copy is shift & c).

mbox

The traditional unix mailfolder format consists of all the messages stored one after the other in a single plain-text file. This is the default format for system mailspools and is the default folder format for mutt.

There are advantages and disadvantages with mbox format. It is slow when removing messages, as the whole thing has to be rewritten, and it can be a mess when several applications want to write to an mbox at the same time. Advantages are that the mbox format is universal and can be read by many other programs (even some in the Windows world).

So use mbox in these situations:

  • Local mailfolders that need to be readable and writable.
  • Transferring mailfolders between systems.
  • Mail backups

gzipped mbox

A variation on the mbox format is mbox compressed with gzip. The only advantage is that the files are somewhat smaller than mbox. The disadvantage is that any corruption caused by multiple applications writing to the same file or any other data-loss is generally not recoverable. Mutt does not support gzipped mbox format by default, so you may have to apply the Compressed folders patch for Mutt.

So use gzipped mbox format in these situations:

  • When you want compressed mbox files for archives of old mail.

Maildir

Maildir is a more recently devised folder format where each message is a separate file in a directory full of other messages.

The advantages of Maildir are that no locking is required, so multiple applications can work on the same mailfolder at the same time without messing up. Plus, having one file per message makes manipulating mail with scripts much simpler

The disadvantages are that some file-systems are very inefficient with both small-files and with thousands of files in one directory.

Mutt can automatically detect Maildir. If you want mutt to create Maildir by default rather than mbox, use this configuration command:

set mbox_type=Maildir

Use Maildir in these situations:

  • Folders where mail is constantly being delivered, moved and deleted such as mailspools and mailing-list folders.
  • Folders that are mounted via nfs; mutt checks to see if file locking works when opening a folder, which means that mbox files have a tendency to be read-only via nfs.
  • Folders with large individual messages; the time taken to open a Maildir is a function of the number of messages, whereas the time taken to open an mbox file is a function of it's total filesize.
  • When you need to write scripts to manipulate messages en-masse, using Maildir format mailboxes is considerably easier than mbox.

MH

MH is a one-file per message format much like Maildir, all the same advantages and disadvantages apply. MH support in mutt is much improved since version 1.2.*.

POP3

POP3 is a way of accessing a remote mailfolder on a POP3 server. Traditionally, mail user agents simply connect to a POP3 mailbox and retrieve everything.

Mutt supports browsing a POP3 account as if it was any other mailfolder. You can sort, delete and read messages without having to retrieve them locally first. However, mutt isn't much use if all you want to do is fetch and download every message to your local machine - see the Collecting mail section for ways to do this properly.

POP3 may not configured for your version of mutt, you can check the compiled-in options by typing this in your shell:

mutt -v

If the output contains +USE_POP, then you have POP3 enabled; if it also contains +USE_SSL, then you have Secure Socket Layer encrypted POP3 enabled as well.

To browse a POP3 mailbox, just hit c to change mailboxes. Then, instead of typing the name of a local mailbox, you can enter the location of your POP3 server. This is much like typing the URL for a page in a web-browser:

pop://username@mail.example.com/

Mutt will ask you for your password and you can browse, delete, edit and save the messages as normal. If your POP3 mail account supports SSL encryption, then you should use pops:// instead of pop:// to enable it.

Note, URL-style addressing for POP and IMAP mailboxes is a recent feature, if you are using mutt version 1.2.* or older, the syntax is different.

Use POP3 mail storage in these situations:

  • When you need to have a small mailbox, such as a mailspool, accessible from various network locations.

IMAP

IMAP is a more sophisticated successor to POP3, the name is an acronym of Internet Message Access Protocol. If the output of mutt -v contains +USE_IMAP, then you have it enabled; if it also contains +USE_SSL, then you have Secure Socket Layer encrypted IMAP as well.

IMAP can be used as a full alternative to local mail storage. You can create sub-folders and manipulate messages in every way. The author of mutt's IMAPsupport has written a complete mutt and IMAP guide.

Mutt's IMAP support is missing extended features like header caching and a disconnected mode for offline reading. If you find yourself using IMAP all the time, then you probably want to use a helper tool like OfflineIMAP to speed things up.

IMAP locations can be accessed in the same sort of web-browser style as POP3 mailboxes:

imap://username@mail.example.com/
imaps://username@mail.example.com/

You can access individual folders in your account by using '/' as a path separator:

imap://username@mail.example.com/path/to/mailbox/

Note, URL-style addressing for POP3 and IMAP mailboxes is a recent feature, if you are using mutt version 1.2.* or older, the syntax is different.

Use IMAP mail storage in these situations:

  • When you have a reliable network connection to your mailserver.
  • For accessing your mail from different locations.
  • When you need to be able to read your mail using different mail user agents.

NFS

IMAP has many advantages as a way of accessing mail over a network connection; it is a high level protocol understood by a large number of mail clients, and if you are connecting via ssl, then it can provide strong authentication and encryption.

The disadvantage of imap is that mail servers tend to be slower than simply accessing the mail-files directly using the NFS 'Network File System' (sometimes known as the 'Nightmare File System').

Use NFS mail storage in these situations:

  • You already have NFS working securely on your network for central storage of home directories.
  • Installing an IMAP server is not a practical alternative.

<< | Up | >>

This document was last modified on 2012-02-28 21:04:57.
Bruno Postle
Copyright © 2001 Bruno Postle and others. This guide is released under the Free Documentation License. http://www.gnu.org/licenses/fdl.txt