posted to this is not a weblog
on sep 29th, 2008 at 21:48

tagged mutt, nerd
and commented on twice

share this page

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.

two comments

tanvir (not authenticated) on october 1st, 2008 at 05:03:11:

thanks for sharing these little nuggets...makes life easier

bernd (not authenticated) on october 7th, 2008 at 03:15:47:

I'm using offlineimap for this stuff. It'll build real maildirs on your local disk.


leave your comment or contact me

if you want to be able to mark your comment as authentic or delete it later, include your e-mail address (it won't be shown on the site). you'll be e-mailed instructions with a copy of your comment.

basic html allowed; be nice
required


optional


optional