How to make and GMail play nicer using IMAP, and GMail demystified


If you’ve got a GMail account, or multiple GMail accounts, chances are you’d like to use a native application like Apple’s to manage your emails.  First, let’s get 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 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 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 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  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  You have to explicitly tell to use these folders how they’re intended to be used.  If you don’t, 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 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. will show this as “flagged” instead of starred.  So to star a message in GMail, simply flag it in– simple.

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

GMail function 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, 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, 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 (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 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, 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  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 ( 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 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, 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 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 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!


32 Responses to “How to make and GMail play nicer using IMAP, and GMail demystified”

  1. Craig Says:

    Thats a good write up. I learned somethings that I did not know.

  2. Bret Kleman Says:

    good goodthis post deserves nothing 😦 hahaha just joking 😛 nice post 😛

  3. Euna Esmond Says:

    Wow! Thank you! I always wanted to write in my site something like that. Can I take part of your post to my blog?

    • joelgreutman Says:

      Thanks for the compliment! You can totally take part or all of it to your blog, but make sure you site it’s source. Thanks!


  4. michael Says:

    sorry to disturb – the gmail subfolders don’t seem to want to appear for me. this just creates a ‘gmail’ mailbox in my inbox, but no subfolders and no separate folders in the ‘sent’ or ‘drafts’ sidebar headings either. did something possibly change in 3.5?

  5. michael Says:

    nevermind! sorry, i worked it out. somehow i had an imap path prefix listed and don’t need it apparently… works as advertised, thx!

  6. Craig Says:

    Thanks, I was wondering why Mail was suddenly showing all my messages *sent* from Gmail in my inbox. All fixed now.

  7. ro Says:

    Hey Joel, thanks for the overview – I switched my accounts to IMAP at the beginning of the year and never looked back.

    That said, here’s a little conundrum I can’t figure out how to solve.

    Say I send myself a test message via It will appear in my Inbox and also in the Sent Mail folder, labeled [Inbox]. So far, so good. Now, when I delete it from my Inbox, it also disappears from my Sent Mail folder. Is there a way to tweak Gmail and that the mail stays in the Sent Mail folder but disappears from the Inbox?


    • joelgreutman Says:

      Instead of deleting the message, have you tried moving it from your inbox into your sent mail folder? This may make it appear twice, but I’m fairly sure that gmail will know what you’re doing and it will appear only once.

      • ro Says:

        That’s a working workaround, aye. Though it’s more work to move the message to another folder than just hitting delete on any of my mail clients. Oh well. Nothing can be perfect, I guess.

  8. Cindy Says:

    Most of my POP3 mail is coming through to Outlook. All shows up in my gmail folder on Outlook. However, some of the email is not making its way to my Outlook inbox. suggestions?

  9. HTK Says:

    Excellent tip! My is working much more integrated with GMail now!


  10. David Rivers Says:

    Thanks so much for the tips about archiving/unarchiving messages in and for synchronizing folders via Mailbox > Use This Mailbox For 🙂 Very, very useful!

  11. You could also put in your table:

    Remove label from a message: Move it to the All Mail folder.

  12. Aden Says:

    hello I like your post!

  13. […] Mail with Gmail and IMAP. Two of them helped me to find my optimal solution (thanks to Joel & […]

  14. marcus Says:

    Great Tutorial! Thanks

  15. Durval Says:

    Great post, I was longing for tips like these.
    And what is the relationship between SMART mailboxes in with GMail, if any?

  16. m6tt Says:

    Hello, thanx for the useful post.
    These kind of settings seem easy once one knows about it, but I’m sure I’d have searched many hours before finding it out.

  17. Erik Says:

    This is great! works so much better now. Thank you for this guide, perfect!

  18. wondershot Says:

    thanks, i think is going to annoy me a lot less now!

  19. Estevao Alvarenga Says:

    Google should put you tutorial instead of theirs…

    Thanks for the tips… bookmarked for formatting HD purposes!!!

  20. Jare Says:

    Hi – I like this article but it doesn’t address a problem I’m having where, when I move emails out of the inbox and into mailbox folders/labels that I have made on Apple Mail client or online, the curved ‘reply’ arrow link/indicator disappears in Apple Mail.

    I’ve noticed other folks mentioning this problem online but nobody has any suggestions of how to fix this. Can you offer any advice?

    • joelgreutman Says:

      Unfortunately, I believe that this has to do with the way that Apple Mail does things internally, specifically with the way it keeps track of messages that have been replied to. I hate to answer with an, “I dunno”, but really… I dunno. Seems strange that when you put something in the “all mail” folder, it doesn’t lose its reply indicator, but when you move it into a label, it does.

  21. Brad Says:

    Hey, great article! I just have one big problem….

    How do I set up a custom Gmail address to play nice with I keep getting connection errors, which means something I’m configuring is wrong. I’m talking about the addresses that you can create using the gmail client, but have their custom suffix, like, as opposed to

    Please help me out if you know the answer!

  22. […] Dogru konfigurasyonu yaparsaniz default mail okuyucusu Gmail arayuzunun yerine cok rahat geciyor. Nadiren web arayuzunu […]

  23. Alex Says:

    This is incredible! Thanks so much!

  24. I wish I’d found this sooner! I started using because Gmail’s web interface seems to be so awful now, and it wasn’t going very well. This should help a lot, thank you.

  25. starbuck Says:

    can I have 2 gmail accounts linked to mail app?
    I have done it but the second one that I just added does not get any mails or does not sync at all.

    I’d appreciate your help. 🙂

  26. Dan Says:

    Great post. I recently found out about telling Mac Mail to correctly map folders to Gmail’s labels (drafts, sent etc). However, the stuff about copying messages into multiple folders to add multiple labels is new to me, simply excellent!! Thanks for this post. Genius indeed 😃

  27. David Madden Says:

    You are a life saver. Seriously, this is exactly the information I needed to better organize my life. Thank you!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: