evan_tech

Previous Entry Share Next Entry
11:25 pm, 8 Mar 04

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
MAILDIR=$HOME/Mail
DEFAULT=$MAILDIR/inbox

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:
online_detect=file
online_file="/etc/network/online"

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:
protocol=smtp
mail_host=my.smtp.server


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.