If you’ve got a GMail account, or multiple GMail accounts, chances are you’d like to use a native application like Apple’s Mail.app to manage your emails.  First, let’s get Mail.app set up so you’ll actually like it, then after that let me explain the differences in the way GMail handles mail and the way that IMAP handles mail, and you should start to see the differences fairly quickly, and how to do things correctly in Mail.app so that things look and behave well when you access GMail via the web:

gmail-mailbox-behaviorFirst, enable IMAP in your GMail account, then follow the instructions on the gmail help page for setting up Apple Mail 3 (please don’t follow the instructions set forth in the “Recommended Client Settings” link).  “But what about POP mail”, you’re asking?  You’re going to want to use IMAP, not POP, trust me: the you of the future will be thanking the you of the past when you access GMail via the web.  After you set up your account, go into the Mailbox Behaviors tab, and set up your behaviors as in the image to the right.  I know that GMail recommends some different settings, but let’s do these for now, as they work well for me.  Close up the Preferences pane, and check out what Mail.app is doing.  You should see new mailboxes popping up and lots of new messages.

[Edit] Make sure all checkboxes are checked.  Prior to this, I followed GMail’s instructions, which include unchecking the “store sent messages on the server” box.  Check it.  Better.

You may be wondering what all of the folders that you see are, and how they operate, let’s look at this next.

What you see in Mail.app and how to use it GMail-like.
gmail_directory_structureLet’s check out at how GMail looks when you first get your account set up in Mail.app.  As you can see, there are lots of “folders”: a folder called “[Gmail]” with some subfolders underneath it, and then siblings of the “[Gmail]” folder that correspond to your GMail labels.

Now you can see folders like “Drafts”, and “Sent Mail”, and it’s obvious to us what those folders are, but it is not obvious to Mail.app.  You have to explicitly tell Mail.app to use these folders how they’re intended to be used.  If you don’t, Mail.app will make its own folders on the GMail server, and you’ll end up having all of your Drafts, Sent Mail, etc. in two places, not neatly filed where they should be.  The folders in question are: Drafts, Sent Mail, Spam, and Trash.  See explanation of “All Mail”, and “Starred” below.

To tell Mail.app to use the appropriate folders for their intended purpose, do the following.  We’ll start with “Drafts”:

  1. Click on the “Drafts” folder so that it’s highlighted.
  2. In the mailbox menu, select Use this mailbox for -> Drafts
  3. Repeat for each of the other folders, “Sent Mail, “Spam”, and “Trash”

The “All Mail” folder is simply all of the messages that have any label applied to them.  The “Starred” folder are all of the messages that you have starred in GMail.  Mail.app will show this as “flagged” instead of starred.  So to star a message in GMail, simply flag it in Mail.app– simple.

Here is a table of GMail operations that you probably normally do, and you’d like Mail.app to do them, too:

GMail function Mail.app equivalent
Apply a label to a message Copy (hold command (⌘) while dragging) the message into the folder that corresponds to your GMail label.  (just like in GMail, messages do not need to be in your inbox to apply labels to them, this process may be used for messages anywhere)
Archive a Message Move it into the “All Mail” folder (a subfolder of “[Gmail]”)
Unarchive a message Move or Copy the message out of the “All Mail” folder (or any other folder you may find it in), and into the “inbox” folder.  Think of this as applying the “inbox” label to a message.
Delete a Message If you’ve followed the instructions above, you should just be able to push the “delete” key on the keyboard, otherwise, move it into the “Trash” folder (a subfolder of “[Gmail]”)
Create a new Label new-label-example-1In the mailbox menu, select New Mailbox…, then set the “Location” drop-down to the root of the IMAP connection, which will be a Globe Icon.  Type in the name of the label (avoid using slashes / or \), click the “OK” button, and you’re done.

Another thing to keep in mind is that items that are in the “inbox”, i.e. unarchived messages, actually are just messages with the “inbox” label. So, to make something appear in the inbox, you have to copy it into the inbox folder in Mail.app, which actually just puts applies the label “inbox”.

Now, let’s look a little more in depth to what is going on behind the scenes:

GMail’s labels: IMAP folders
GMail’s labels are IMAP folders.  If you’ve noticed, you can have multiple GMail labels on any given message.  Let’s suppose you have a label called “receipt” and a label called “eBay”, and you get an email that is a receipt for a purchase that you just made for a new toaster on eBay.  You’d like it to have both of the labels “receipt” and “eBay”.  With GMail, this is easy.  You simply apply both labels to the email (or thread).  But how can a message be in more than one folder, didn’t I just say that GMail’s labels like IMAP folders?  Yes, I did… and they are… kindof…

This is the beauty of Google Mail.  They took technology that was pre-existing and repackaged some if it, rewrote some of it, did a little magic, and made everyone think it was something totally new (which it was…mostly).  GMail’s mail servers are not a typical mail servers, as GMail’s messages can have more than one label at the same time, whereas any particular message on a normal (IMAP) mail server can only exist in one folder, you can make copies of said message, but then you’d have multiples of the same message, each still residing in only one folder.  But for simpliciy’s sake thing of applying a label in GMail as the IMAP equivalent of copying a message into a folder.  Removing a label in GMail is the IMAP equivalent of deleting a message out of a folder.  However, if you copy a message to a different folder via Mail.app, the message isn’t actually copied.

All this is evidenced by a couple of things.  Let’s do an experiment:

  1. First, open up your newly configured Mail.app (or whatever client).
  2. Open up a web browser and log into GMail.
  3. Send yourself a test message, the subject can be anything, but in order for the test to work, attach a file to the message that’s around 10 MB, something of known size, but big enough to make a dent in your “used space”
  4. Apply two labels to the test message.

Now, here’s the test.  In your Mail.app program, navigate to your inbox, you’ll see the message there.  Now find the folders corresponding to each label that you applied in GMail, you’ll see the message in both of those.  You can also see the message in the “All Mail” folder.  You may be thinking, “well all that means is that GMail just copies the message into different IMAP folders, that’s not special!”.  Actually it is special.  Go back to your GMail web interface.  If you look at your used space (it’s down below the messages area), you’ll notice that every time that you apply a label to that message with the large attachment, your used space does not increase.  If you just think that the used space isn’t updating dynamically, try refreshing the page or logging out and logging back in, you’ll see that your used space remains the same.

Here’s another test that you can try that will further prove this, and bring up another point:  in Mail.app, find the message in question, and copy it (don’t move it) to one of your labels/folders.  To copy, simply drag the message, and before you drop it hold down the command (⌘) button, you’ll see the green plus sign appear indicating a copy, then drop it into the folder.  Notice how long it takes to complete the request.  On my internet connection (which isn’t the fastest in the world), it took mere seconds– surely not long enough to upload email with a 10MB attachment.  As promised, this brings up another point.

How IMAP actually does things
IMAP stands for Internet Message Access Protocol (see imap.org).  I love IMAP.  It makes my life so much simpler.  I know that everything that I do on my computer actually happens real time on the server.  When I delete a message, it’s also gone when I log into my webmail.  When I move it, it’s also moved on the server.  But the best part for me is this– if I have to reformat my computer, or my mail application crashes, or something else tragic happens, when I set up my eMail again, it’s EXACTLY how I left it.  Nothing to back up, no worrying about if I got all of my eMail client’s files on my external hard drive, etc.

With IMAP, it’s not that you do some operation on your locally stored email and it also lets the server know; it’s that the only thing that’s actually happening is your mail client (Mail.app in our case) is using a set of known commands to tell the server what to do with any given message or set of messages.  Everything IMAP does is server-side.  Emails aren’t even really stored on your computer if you don’t want them to be (although most of the time they are cached so they don’t need to be re-downloaded every time you want to access them (and to make searches quicker)).

So, when you “copied” that message with the large attachment into a different folder, what actually happened was that Mail.app told the GMail server to copy the message from one place to another, it didn’t actually do the copying, it just issued the command of what to copy and where to copy if from and to.  What the GMail server did with that command is its own business– and in this case, GMail simply applied the label name of the folder that you copied into, also leaving the label “inbox” on it.  Genius!

When you move a message from say, your inbox into an IMAP folder, however, GMail does two operations to compensate.  For example: in Mail.app, if you move a message from your inbox into the eBay folder, GMail applies the label “eBay”, and removes the label “inbox” from the message.

So, the beauty of the whole thing is simply what GMail reports back when Mail.app requests something. For example, if you click on the “All Mail” folder, GMail will send back ALL of you email from any label, minus Spam.  If you click on the “eBay” folder, GMail will send to Mail.app all of the messages that you have applied the “eBay” label to, regardless if they have other labels applied to them or if they are in the inbox.

So there you have it.  Hopefully you got something out of this post.  Leave a comment if you did!