Evan Martin (evan) wrote in evan_tech,
Evan Martin

offline mail, the full story

This is what I ended up with:

Online Access
I typically ssh into my mail host and use mutt. The host uses uw-imapd and I don't control that, so to make offline syncing work you have to go through imap.
That host has mbox folders (again, uw-imapd) and I keep all of my mail, including my inbox, in ~/mail. To make procmail do this, set

To make mutt use faster and easier, we can use imapd directly, bypassing authentication and all that:
set tunnel="/usr/sbin/imapd"
set folder=imap://localhost/Mail
set spoolfile=imap://localhost/Mail/inbox

Remember to configure all of your mailboxes relative to your "folder", like
mailboxes ! =mymailbox =mydir/submailbox

Offline Reading
My laptop uses offlineimap to retrieve my mail. It stores it in maildir format. To make offlineimap and uw-imapd happy, there are some settings to tweak:
[Repository Local]
type = Maildir
localfolders = ~/mail/danga
sep = /

This says my (1)local copy is (2)maildir, stored in (3) ~/mail/danga, with (4)slashes separating folders (so I get a directory hierarchy.
[Repository Remote]
type = IMAP
ssl = yes
remotehost = imapserver.com
remoteuser = martine
remotepass = mysecretpassword
reference = Mail
nametrans = lambda foldername: re.sub('^Mail/', '', foldername)

The "reference" bit means "all my mail on the remote host is in the Mail subdirectory", and is needed for uw-imapd.
The "nametrans" bit strips off that Mail directory when I actually store the mail locally.

Offline Sending
I use masqmail to store a queue of messages that only get sent when I'm online. The Debian packages has a nice debconf interface, which nicely leaves you with a non-functional setup. I did it anyway to get all the defaults in place.
You need masqmail to somehow learn you're online. By default it has scripts that run with ifup and ifdown that create a file if you tell it to in /etc/masqmail/masqmail.conf:

It inserts into that file the network name, which is mapped via a config parameter to a routes file:
online_routes.default = "/etc/masqmail/default.route"
maps "default" to "default.route", which I created simply:

Now the ifup masqmail script needs to be told to use the name "default". After some poking around, I found that adding a name parameter in my /etc/network/interfaces was what I needed:
iface eth1 inet dhcp
name default

Now when I go online, the if-up.d masqmail script creates the file and pokes masqmail, which dumps my queued mail. When I ifdown the interface, it removes that file and masqmail goes back to queuing.
There's still something wrong with the from address in the mails. I think I need to configure mutt on my laptop.

That was way too difficult.

  • blog moved

    As described elsewhere, I've quit LiveJournal. If you're interested in my continuing posts, you should look at one of these (each contains feed…

  • dremel

    They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…

  • treemaps

    I finally wrote up my recent adventures in treemapping, complete with nifty clickable visualizations.

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.