Two years ago I documented my configuration of mutt, offlineimap and courier imap. This combination gave me complete offline access (critical on a laptop) including folders and sending new messages. Additionally it scaled painlessly to multiple servers and clients, without my needing to think about keeping them in sync. Life was good, for a while...
More recently, I decided that I'd like to use mutt with IMAP directly on some client machines (workstations) and offlineimap on other machines (laptops). I rewrote my muttrc to be preprocessed with m4, and everything was rosy, except for sending via Outbox...
The method I was using depended on a helper script (mailout) which called safecat to deposit mail in the Outbox. That script no longer suffices, because it needs to save to IMAP rather than local maildir. Of course we want to use mutt's existing connection to the server rather than create another connection in the script! So I needed to find a way to make it work within mutt.
What started as an elegant hack quickly turned ugly. I tried setting $sendmail=/bin/true and used $record to fcc the message to the IMAP Outbox. This hack generally worked. The fcc-status patch is needed to prevent "Status: RO" (screws up the recipients that use mboxes; the mail shows up as already-read). Additionally mutt doesn't provide a method to fcc to more than one folder, so to get an fcc other than the Outbox, I used the write-fcc function in the compose menu. That was borked though because it lacks the Message-ID, encryption/signing, date, etc!
Moreover it all falls apart when bouncing (remailing) messages, because that code path calls mutt_invoke_sendmail directly, and of course no fcc is done.
Finally I realized that these hackish methods were going nowhere fast, so I implemented Outbox support directly in mutt. I call it "sendbox" because I think that's more explicit. Plus mutt already has an internal variable Outbox that corresponds to the $record setting, and I wanted to avoid confusion.
To use this feature, one does something like:
set sendbox=imaps://imap.domain.com/INBOX/Outbox set use_sendbox=yes
...then all mail is sent by saving it to the Outbox instead of calling sendmail.
Part 2 in this series will explain this configuration in more detail and provide the patches to make it happen. Later parts will document some other interesting (at least to me) parts of my mutt setup.