Search

Enter a search word or two and press return to see the search results.

Who am I?

Hi, I’m Graeme and these are my notes, from my messy desk. I started this blog because Google proved to be more useful at finding content than anything else I’ve used.

So I started adding my own content in the hopes that Google would index it and allow me to find things again in the future.

It works.

You can find out more about me here, and you should follow me on Twitter here.

Keeping up

You can automatically receive new content here by subscribing to the “Blog RSS” (link below). This is the easiest way to keep up with what I write here.  See this BBC article for a good introduction on RSS and keeping up with the goings on of the Internet more easily.

« links for 2006-11-21 | Main | OMG! EXTREME CRITICAL EMERGENCY!! EVERYTHING'S BROKEN! People are DYING! »
Monday
20Nov2006

Howto: Using Mail.app to archive your GMail email

I'll write this while I have the chance, since my mail inbox will be [strangely quiet](/2006/11/20/omg-extreme-critical-emergency-everythings-broken-people-are-dying/) for the next few hours...

As regular readers will know, I recently [switched to using GMail](/2006/10/19/switching-to-gmail-from-dreamhost/) for my regular mail using their [Google Apps for your Domain](https://www.google.com/a/) 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 (, 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.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (8)

No, the labels are not provided in POP3. If it were IMAP, then one label could be included as a folder name, but I don't see that happening anytime soon.

January 1, 2007 | Unregistered CommenterWhat is Gmail?

[...] OooO [...]

January 11, 2007 | Unregistered CommenterKikkoman » Gmail –

My experience is exactly like Chinarut's, in addition to what Mathie says: It did load in batches of about 500, then stop until the next check for new mail. But nevertheless, Mail.app simply will not retrieve any new Gmail after fetching just under 50%.

Seems there's more going on here.

April 15, 2007 | Unregistered Commenterjccc

martin, you can use smart folders in mail.app. You can't import your labels, but you can emulate them that way

April 16, 2007 | Unregistered Commenterchris t

Good post, but what happens when you send an email from Mail.app?

I noticed that if you have gmail set up for Multiple email clients on one gmail pop account (using "recent:username@gmail.com" in your username box in your mail clients), that all email gets sent to your Sent folder and then the next time it downloads from gmail it will obtain a duplicate copy of that sent email you mailed out.

If only you could tell Mail.app to not save your sent emails then it would be ok! So ive been working on a workaround using applescript using mail.app's rules. It is a very simple script that scans the Message-Id: header from the incomming email and compares it with the Message-Id of first email listed in the Sent folder. If they are equal, it moves the message to the trash, if they are not equal, it moves the message to the Sent folder. This Rule is only filtered towards emails that i send out.

The problem is that this makes Mail.app crash randomly, and on one bizarre ocassion, it started to download the same message everytime i sync'd with my pop gmail account. Very odd. Hopefully apple can fix mail.app's problems with applescript.

April 19, 2007 | Unregistered CommenterRobert

This is exactly what I've been looking for. The Google set up instructions refer to Apple Mail, however. How can I set this up on a PC?

April 23, 2007 | Unregistered CommenterSharon

good to hear others had a similar experience as I. I pretty much gave up on archiving my email as much of a history freak I am.

I even tried to see if gmail IMAP would help - it works great on the iPhone but it was a nightmare on Mail.app (even on 10.5.x) - it just doesn't handle Google Mail accounts with high volume and in my case, over 100 labels. I am not sure what's going on, reconfigured it to POP3 and now use Mail.app for sending emails only for those apps (like iPhoto) that insist on this transport.

that said, if anyone discovers a way to archive my mail so I can have an offline searchable archive, let me know - i'm game! command line solutions may very well be acceptable if the search facility is good too!

February 20, 2008 | Unregistered CommenterChinarut

Thanks the author!

December 19, 2008 | Unregistered Commenterslenouple

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>