This is part 2 of a series that started here.
Before jumping into the patch and configuration details for using sendbox, let's take one step back and review the reasons for sending via IMAP. Sending email via IMAP gets mixed reviews in the community because it is non-standard, seldom supported by mail user agents (such as mutt), and supported by few IMAP servers (I'm only aware of Courier IMAP). The argument is that mail should be sent via SMTP and received via IMAP, and isn't that good enough?
I think there are good reasons to consider using IMAP for sending:
For me, these reasons trump the naysayers' arguments. Overall, sending email via IMAP is more elegant than splitting the operations between IMAP and SMTP, and elegance in software attracts me irresistably.
Let's start with the patch then talk about configuration details to make use of it. After all, the patch introduces latent functionality that won't take effect unless you change your configuration. But configuration is useless without the patch.
Here are three options for obtaining a patched mutt:
hg clone http://n01se.net/gentoo/overlay overlay-noise export PORTDIR_OVERLAY="$PWD/overlay-noise $PORTDIR_OVERLAY" emerge mutt
echo deb http://n01se.net/agriffis/debian sid main >> /etc/apt/sources.list echo deb-src http://n01se.net/agriffis/debian sid main >> /etc/apt/sources.list apt-get update apt-get install mutt
wget http://n01se.net/agriffis/mutt/mutt-1.5.12-sendbox.patch
There are three ways to use Courier's Outbox (if you learn of another IMAP server that supports the Outbox concept, I'd love to hear about it). The first way is to simply specify it in your configuration. For an IMAP configuration, that would be:
set sendbox=imaps://imap.domain.com/INBOX/Outbox set use_sendbox=yes
This simplistic configuration works if the administrator of your mail server has enabled Outbox by default. Unfortunately this is seldom the case. More commonly, you'll need to the second way, which is to ssh into the server and start imapd yourself to enable Outbox. This is simpler than it sounds, just add to the above:
set tunnel="ssh -q server.domain.com env OUTBOX=.Outbox SENDMAIL=/usr/sbin/sendmail /usr/sbin/courier-imapd .maildir"
To make this work with multiple servers, you can use account hooks.
If you're an offlineimap user, your offlineimaprc should have something like this:
[Account email] localrepository = local remoterepository = remote [Repository local] type = Maildir localfolders = ~/mail sep = . [Repository remote] type = IMAP preauthtunnel = ssh -q server.domain.com 'env OUTBOX=.Outbox SENDMAIL=/usr/sbin/sendmail /usr/sbin/courier-imapd .maildir' nametrans = lambda foldername: re.sub('^INBOX\.', '', foldername)
and your muttrc can then contain simply:
set sendbox=~/mail/Outbox set use_sendbox=yes
Just don't forget to run offlineimap after sending mail from mutt, otherwise it won't leave your local Outbox!