Tag Archives: imap

Moving to Mac OS X: from Thunderbird to Apple Mail

I recently got a shiny new MacBook Pro, and of course have been instantly hooked. In less than a week I seem to have learned my way around with equal proficiency to that other inferior operating system I’ve used for so long.

However, some habits die harder than others. I kept using Thunderbird since all my mail was stored in that format and was tagged up with labels (well, they are actually tags now that its Thunderbird 2.0).

Some guy I know had been raving about how good Apple’s mail was, especially in combination with MailTags and Mail ActOn. I was keen to try it out, but not quite brave enough to switch (and even now, I’m still considering this an experiment). Most of my mail is POP from my ISP, so its stored locally.

Given that Thunderbird can’t read Apple Mail stores and vice versa, I needed a solution that wasn’t all or nothing, and something that would hopefully allow me to read and store my mail on my other machines without going through the POP keep/delete hoops which are a bit gross. I wanted one canonical store.

Given that I don’t run a server constantly, I’ve decided to use my primary machine, the MacBook, to POP all my mail to and run an IMAP server locally to read the mail from both Apple Mail and Thunderbird. The only gotcha will be that I won’t be able to share the incompatible tags, but that’s ok. If I need to move between machines I won’t be using them and I can always open the other client on this one.

So, here’s how I went about it for those that would like to try it. It was fairly straightforward (I’ve never done this before and I was completely set up in 4 hours). Still, I recommend doing some additional reading around each of the steps so you understand what you are doing – you don’t want to lose your mail or turn your box into a SPAM relay.

Set up Postfix

Postfix comes pre-installed on Mac OS X, so all I needed to do here was configure it. I needed 2 things – to change it to use Maildir (IMAP won’t allow subfolders if you are using mbox), and to get it to listen on localhost port 25 so I could relay mail from localhost (not strictly necessary, but I use that so that it is easier to work with the defaults for javamail, for example).

So, editing /etc/postfix/main.cf, I add:

# This is required to get postfix to start up
myhostname = localhost.localdomain
# Use maildir instead of mbox
home_mailbox = Maildir/

You’ll also want to set relayhost if you are going to relay your mail, and be sure to configure the networks to keep that to only come from your machine or network.

Next, to get it to start on boot I followed these instructions (see towards the end).

At this point, I sent a test message:

echo test | mail -s 'foo' brett@localhost

Seeing it arrived in my maildir, I used mail to read it in the terminal.

Set up Dovecot

Dovecot needs to be installed, and unfortunately isn’t in fink, so I used the DarwinPorts version. It’s one release behind at the moment, but I already had it installed before I realised that so I’m sticking with it for now. With DarwinPorts installed, I ran:

sudo port install dovecot

The configuration goes pretty much as the docs say. I created /opt/local/etc/dovecot/dovecot.conf from the example in the same directory and added these options:

default_mail_env = maildir:~/Maildir
mail_extra_groups = mail

I haven’t yet tried the maildir_copy_with_hardlinks = yes setting recommended for performance.

I tried to disable SSL support since I’d only be running this locally, but that dies with a Signal 10 on RC6 from DarwinPorts, so I turned it back on and generated a fake certificate. I copied the dovecot-openssl.conf file from a source distribution I downloaded as I couldn’t find one from the DarwinPorts version. That was used to generate the certificate using mkcert.sh from the same source distribution.

For the PAM settings, I followed those here, but none of the other steps were necessary – DarwinPorts already created the dovecot user and launchd script that just needed to be activated . Instructions for that appear during the installation, but at a later date it can be started using launchctl:

sudo launchctl load /Library/LaunchDaemons/org.macports.dovecot.plist
sudo launchctl start /Library/LaunchDaemons/org.macports.dovecot.plist

So, now that I had dovecot running, I opened up Apple Mail, added an account for it, and checked that my earlier test mail was there. I sent another one for good measure to see it was picked up.

Set up Fetchmail

Update 3/9/06: I removed the fink installation instructions here since the version in there was waaaay out of date. Instead, get fetchmail from BerliOS and follow the normal configure/make/make install steps (also listed in the article below). I’ve updated the launchd configuration below to use /usr/local/bin instead of fink’s /sw/bin.

These instructions are useful for setting it up. I started out with the keep option turned on, but other than that my config was the same. (Update 23/8/06: I’ve since removed the StartupItems entry for FetchMail so that isn’t needed from this guide. See below.)

I turned these all on, tested, and once confirmed it was working, rebooted and it all came up. So now I get to POP my mail regularly, and can read it from both Thunderbird and Apple Mail using IMAP. Next adventures will be moving the existing mail there, and backing it all up!

That’s it! Thanks to John, Jesse and Jason for putting up with my questions on various aspects. I was being extra paranoid, but this ended up working very nicely.

Update 23/8/06: I discovered that under the above set up that fetchmail would stop running whenever I put the macbook to sleep and I’d need to kick it again when I opened it back up. To correct that, I removed the StartupItems entry for FetchMail created above, and created a launchd item instead. This is /Library/LaunchDaemons/de.berlios.fetchmail.FetchMail.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

I created this using Lingon, which is a nice launchd editor John pointed me at.