Making Mutt Useful Offline
I've been using
mutt
as my MUA for over 8 years now.
Long ago I would ssh to my server and run it on local Maildirs, but as soon as I
started using smartphones and multiple computers I had to switch to an IMAP+SSL
setup.
Mutt's header_cache
option has long made accessing large mailboxes snappy, and
the recent message_cachedir
option available in 1.5 makes browsing through
messages with attachments equally snappy over IMAP.
A useful side effect of message body caching is that it provides an offline copy of entire mailboxes which get synchronized automatically and can easily be read in Mutt as a local mailbox… well, almost.
Because the message caches are just stored in a directory one-message-per-file
and one-mailbox-per-directory, this doesn't match any known mailbox format so
Mutt will just error out saying it's not a mailbox when trying to read it with
mutt -f
.
However, if those messages are saved to a cur/
subdirectory and a new/
subdirectory is also present, Mutt will recognize it as a Maildir and read it
properly.
Yes, the files inside the cur/
directory will not have "proper" names with a
colon, version number, comma, and flags, but it's enough to get Mutt to read
them.
I made a
patch to Mutt 1.5.18
that changes the message cache functions to write to a cur/
subdirectory and
ensure that a new/
subdirectory also exists.
With these in place and all of your folders cached, an offline .muttrc
can be
created:
source ~/.muttrc
unset spoolfile
unset folder
unset postponed
unset record
# required to prevent imap connections even though spoolfile and folder are changed,
# for some reason
set imap_passive=yes
# point to the appropriate directories
set spoolfile=~/.mutt-cache/imaps:user@mail.example.com/inbox/
set folder=~/.mutt-cache/imaps:user@mail.example.com/
and then Mutt can be invoked as (or an offline_mutt
shell alias set to):
mutt -R -F ~/.muttrc.offline
which will provide read-only views of all of your mailboxes and retain all of the other macros and searching, filtering, and other functions you already have configured in Mutt.
Note: not using -R
may change message flags which will rename the cache files
and cause them to get out of sync.