I’ll write this while I have the chance, since my mail inbox will be strangely quiet for the next few hours…

As regular readers will know, I recently switched to using GMail for my regular mail using their Google Apps for your Domain offering. I’m extremely happy with it – there are a few wrinkles, but on the whole it’s a big improvement on my email workflow.

One thing I was missing: an offline archive of my email. Sometimes I am sitting in a random place without Internet access. And I’m not always the most organised person in the world about extracting useful information from my email when I should. Case in point: I was meeting some people for lunch in Leith last Thursday. The car was in for service, so I was taking the bus and was running a little late. I’d forgotten to update my mobile phone with any of their phone numbers. I know, I thought, I’ll just check on my laptop. I felt silly enough pulling out my laptop on a public service bus in the middle of a less than salubrious area of the city. I felt even sillier when I realised I didn’t have their phone numbers in my address book and, though they were definitely in my inbox, I couldn’t access it!

Anyway, that’s the background. Over the weekend, I sorted out a solution. Since I created my GMail account, I have had POP access switched on, but I’ve never used it, so I have a nice backlog of mail ready to pick up with Mail.app. What do I do with it, though?

Well, I decided that my workflow was to use GMail’s interface as much as possible, only using Mail.app as an offline archiving tool (which is also spotlight searchable, etc). It also has the advantage that I can queue up emails to send offline too.

So how did I set it up? Let’s start from GMail’s side of things.

Options for setting up gmail

In your Settings, go to the Forwarding and POP tab. First of all enable POP access for all mail (Enable POP for all mail) since you want your existing GMail archive available offline too, right? If you don’t you could enable it only for new mail, I guess. For the second option, select to keep the mail in your inbox, rather than archiving or deleting it. That way, downloading email to Mail.app doesn’t affect its status in GMail. Save the changes.

Mailboxes created in Mail.app That's it for email. Now for Mail.app. Create your account for GMail in Mail.app by following [Google's setup instructions](http://mail.google.com/support/bin/answer.py?answer=13275&hl=en_GB) . It's probably best to allow it to finish collecting mail before you go much further (to creating the rules) just to avoid confusing Mail.app. Meanwhile, I have created two different folders: `Archive` and `Mailing Lists`. Everything I receive that I haven't just deleted in the GMail interface goes into Archive, except for mailing lists which I keep separate. This is mostly because I only keep *some* mailing list mail (work lists, that kind of thing) and I haven't created rules to manage that in a more fine-grained manner yet. So, if you're following along at home, create these two folders to push mail into.

Let’s create some rules to push incoming messages into the right place. First up, when you’re retrieving messages from GMail, it kindly also contains the messages that you sent too, so you have an entire conversation. Excellent, though perhaps a little confusing at first. My first rule is one to push the messages I sent into my usual Sent folder. (I can always recombine conversations again with smart folders, but it’s useful to make the distinction at this stage.) I created the following rule:

Rule to push sent messages into the sent folder

You’re looking for two rules, and for either of them to match. The first is if the ‘From’ address contains your own GMail email address (foobar@gmail.com, for example). This covers all the messages you send directly from your official GMail address. The second is to match the ‘Sender’ header. You won’t find it listed in the drop-down by default. Select the bottom entry – Edit Header List..., click the + to add a new entry and enter Sender as the value. I don’t know for sure, but it’s probably case sensitive, so best to make that a capital ‘S’. Now click ‘OK’ and select the drop-down again and ‘Sender’ should appear. You want to see if that’s equal to your GMail email address. That will cover sending from any other address you have set up in the accounts tab of your GMail. The actions to perform are to move the message to your ‘Sent’ folder, mark it as read (you read it while you were writing it, right? :-) ) and stop evaluating any more rules. Click OK to save the rule. It will ask if you want to apply the rule to currently open mailboxes. Click ‘yes’ to have it process the messages already in your inbox, and you should notice all the mail you sent magically disappear.

Rule to push mailing list mail into another folder

You’ll need to edit the headers list again and add List-Id as another header. Be careful with the case again, just to be safe. I’m currently matching all mailing list mail (or at least every one that has a ‘.’ in it and most List-Ids are the address of the list), but you might want to tweake this more carefully so that it doesn’t catch email you want to keep in your own archive. Again, mark the messages as read and stop evaluating further rules. Save the rule by clicking OK and apply it to your inbox. All the mailing list mail should magically disappear into the right folder.

Rule to move every other message to an archive folder

Finally, let’s create a last rule to move every other message to an archive folder. Move all matching (ie all!) messages to your archive folder and mark as read (since you’ll probably have read or be about to read them in the GMail web interface). Click OK and apply the rules to your current inbox.

You should now have an empty inbox, the mail you sent in your Sent folder, all the mailing lists pushed out the way and everything else in your email archive. You can spotlight for messages and you have a backup should something go wrong with your GMail account. Everything will happen automatically every time Mail.app picks up mail.

A Sneak Peek at
The Internet

If you enjoyed this article, you might be interested in my new project, A Sneak Peek at The Internet. What happens when you enter www.facebook.com into your web browser and hit return? A Sneak Peek at The Internet will take you on a deep dive through the network stack, from HTTP, SSL, TCP and IP, all the way down through the data link layer, back up to Facebook's data centres, and then on the return journey back to the browser.

There's more fun, excitement and peril than a Disneyland rollercoaster!