Configure Gmail IMAP accounts properly in Apple Mail and on the iPhone

Configuring a Gmail IMAP account properly in desktop email clients can be tricky, since many desktop clients will try to create their own Drafts, Sent Messages, etc. folders and not use the ones already provided by Gmail.

Enabling IMAP on your Gmail account:

Log in via the web interface (http://www.gmail.com/‘ if you’re using plain Gmail, ‘http://www.google.com/a/{domainname.com}‘ if you’re using Google Apps For Your Domain), then click the ‘Settings‘ link in the top right-hand corner of the page. Choose the ‘Forwarding and POP/IMAP‘ tab, then disable POP and enable IMAP.

Click on the ‘Labs‘ tab, scroll down to the ‘Advanced IMAP Controls‘ item and enable it, then scroll to the bottom of the page and click the ‘Save Changes‘ button.

configure-gmail-imap-apple-mail-iphone-01

Configuring the Gmail IMAP account in Apple Mail:

Launch Mail.app and open its Preferences window by clicking ‘Mail‘ -> ‘Preferences…‘ in the menubar at the top of the screen.

Switch to the Accounts tab and click the ‘+‘ button to add a new account. Enter your Full Name, Email Address and Password, then uncheck the ‘Automatically set up account‘ checkbox and click the ‘Continue‘ button. Change the Account Type to IMAP, give the account a name under Description, change the Incoming Mail Server to ‘imap.gmail.com‘ and fill your User Name (your full email address) and Password in, then click the ‘Continue‘ button.

Specify a name for your Outgoing Mail Server under Description (e.g. ‘Gmail SMTP’), set the Outgoing Mail Server to ‘smtp.gmail.com‘, check the ‘Use only this server‘ checkbox, check the ‘Use Authentication‘ checkbox, and fill your User Name (your full email address) and Password in again. Click the ‘Continue‘ button, then the ‘Create‘ button to create the account.

configure-gmail-imap-apple-mail-iphone-02Select your Gmail account in the Mail Preferences window. Click on the ‘Mailbox Behaviors‘ tab and turn the ‘Store draft messages on the server‘, ‘Store sent messages on the server‘, ‘Store junk messages on the server‘, ‘Move deleted messages to the Trash mailbox‘, and ‘Store deleted messages on the server‘ checkboxes on.

Change the ‘Delete sent messages when:‘, ‘Delete junk messages when:‘, and ‘Permanently erase deleted messages when:‘ settings to ‘Never‘, then select the ‘Advanced‘ tab and change the ‘IMAP Path Prefix‘ to ‘[Gmail]‘.

Close the Mail Preferences window and look for the Gmail account’s name at the bottom of the left-hand sidebar. Flip the triangle next to the account’s name to show all folders inside it.

In the next step, you can either set Mail to move deleted messages to All Mail (which will require that you drag messages to the Trash folder on the server if you want to permanently delete them), or to Trash (which will require that you drag messages to the All Mail folder on the server if you want to preserve them):

Click on the ‘All Mail‘ (or ‘Trash‘, depending on your preference) folder, choose the Mailbox menu item in the menubar at the top of the screen, then choose ‘Use This Mailbox For‘ -> ‘Trash‘.

Click on the ‘Drafts‘ folder, choose the Mailbox menu item in the menubar at the top of the screen, then choose ‘Use This Mailbox For‘ -> ‘Drafts‘.

Click on the ‘Sent Mail‘ folder, choose the Mailbox menu item in the menubar at the top of the screen, then choose ‘Use This Mailbox For‘ -> ‘Sent‘.

Click on the ‘Spam‘ folder, choose the Mailbox menu item in the menubar at the top of the screen, then choose ‘Use This Mailbox For‘ -> ‘Junk‘.

Configuring the Gmail account on an iPhone:

Go to the iPhone’s Home screen and launch the Settings application. Select  the ‘Mail, Contacts, Calendars‘ option, choose ‘Add Account…’, then choose ‘Other’ (The Gmail option listed on this screen is for POP account setup).

Enter a Name, Address, Password and Description, then touch the ‘Save‘ button. Choose the ‘IMAP‘ tab, enter ‘imap.gmail.com‘ as your Incoming Mail Server and ‘smtp.gmail.com‘ as your Outgoing Mail Server, then enter your User Name (your full email address) and Password for both, then touch the ‘Save‘ button again.

Once account setup has finished, go to the main screen of the Settings application, choose your email account, and select the ‘Advanced‘ item.

Change your ‘Drafts Mailbox‘, ‘Sent Mailbox‘, and ‘Deleted Mailbox‘ settings to their respective folders in ‘[Gmail]‘, then change the ‘Remove‘ setting to ‘Never‘. Change the ‘IMAP Path Prefix‘ setting to ‘[Gmail]‘.

configure-gmail-imap-apple-mail-iphone-03

 

Related posts:

  1. Configure a Quake-style dropdown Terminal in Mac OS X
  2. Setting up GatorPeeps on your Mac and iPhone
  3. Jailbreaking, Activating and Unlocking my first-generation iPhone from OS 2.2 to 3.0
  4. Sending emails with attachments using PHP’s mail() function
  5. Exporting your iPhone’s SMS Message Database to a CSV file
Twitter Digg Delicious Stumbleupon Technorati Facebook Email

43 Responses to “Configure Gmail IMAP accounts properly in Apple Mail and on the iPhone”

  1. Chris Kresser Reply 21 Jun 2009 at 20:56

    Hello,

    Thanks for providing such clear instructions.

    However, after following them I now see every email I’ve ever received in my inbox on Mail OS X! If I delete them, they disappear temporarily, but then reappear a few moments later.

    Do you know what might be happening?

  2. Hi Chris

    On the left side of the Mail.app window, which folders does it display on the server?

  3. Chris Kresser Reply 21 Jun 2009 at 21:15

    Thanks for your quick response.

    This is kind of embarrassing, but I just realized that the reason the emails are all appearing in my inbox is that they ARE in the inbox in my Gmail account on the web.

    For a while I was having my Gmail forwarded to MobileMe, so I didn’t bother archiving any of the messages in my inbox. So after setting up Gmail on Mail.app, of course all of the messages in my Gmail inbox showed up in my Mail.app inbox. That would be expected.

    I guess I’ll have to go back to Gmail and archive all of those messages in the inbox!

  4. Hi, Do you know how to change from POP gmail to IMAP in Mail? I originally set up my Mail client using POP Gmail (because I didn’t realize I had the IMAP option). So, now I enable IMAP in Gmail settings, and then changed my Gmail account’s incoming server to imap.gmail.com under the account settings in Mail. Mail seems to be accessing the IMAP server, but Mail still thinks the account type is POP. I can’t find any option for changing the account type unless I set up a new account. And I’d rather not have to download all my emails and delete all the old ones again–a process that took way too long the first time.

    Thanks in advance!

  5. Hey Shawn

    Sorry, as far as I know Mail.app can’t switch a POP account to an IMAP account due to the way the messages are stored both on the server and locally.

    You could, however, create local Mailboxes and move the messages from your POP account to those, then delete the POP account and set up the IMAP account after moving unnecessary messages out of your Inbox and into labels on the Gmail Web Interface (these labelled messages will appear in folders under the IMAP account in Mail.app).

    This will then result in you having an IMAP account and a bunch of local Mailboxes for the old POP messages. The IMAP account in Mail will contain only the messages in your Inbox, but will download messages from other ‘folders’ if you click on them.

  6. Shawn, you likely setup the Gmail account using the “set this account up automatically”. Unfortunately Apple still leaves that as a default to a POP account. You will have to setup a new one, but make sure you uncheck “set this account up automatically”.

    Now set it up using imap settings. As shown above.

    Hopefully Apple will fix this some time as imap really should be the default.

    • Update to this… if you are using Snow Leopard & it is up to date, automatically setting you the gmail account works as imap and gmail is setup with imap activated by default. I let it do it itself with no problems (unless you are using gmail with your personal domain) and it works perfectly.

  7. Hi willem,

    Thanks for the writeup. I have a few queries.

    1. My labels have all disappeared from the left hand side. Do I need to change them in Gmail to prefix them with IMAP or something? I read this elsewhere.

    2. The main reason I wanted a better setup was so messages that were deleted in Apple Mail/iPhone were moved to the correct spot in Gmail and then deleted properly. I get hundreds of emails a day so don’t need to keep them all, even though I have heaps of space in Gmail.

    thanks.

  8. Ok to answer my own question, In gmail I must prefix the labels with [Gmail]/

    ie [Gmail]/personal

    It looks weird in the web interface but I use Apple Mail mostly anyway.

  9. Me again, testing this shows that messages I delete in Gmail get moved to the right spot in Gmail, ie the Trash, and emptying the Trash in Apple Mail has the same effect in Gmail! Thanks for the tips!

  10. I set up my gmail account on mac mail correctly (imap), it the only folder I have for the inbox/incoming mail is “ALL MAIL”. However, this contains both incoming and outgoing mail. I do have a sent folder which is correct, but how do I configure it so that i have an “INBOX” folder with only incoming mail? Is that possible?

  11. Do you need to change the IMAP prefix? I did and got an error message for my folders. Changing it back, everything works great.

  12. Awesome, thanks for making it so easy to follow. I’ve been wanting to do that for sometime and now it’s done! THANKS! :-)

  13. Thanks for your advice Willem, everything works fine now. There is only one detail which is not very nice, at least on my computer. If I save a draft in Apple Mail, it regularly sends copies to the online trash folder of Gmail. Do you know this problem? And how to get rid of it?

  14. I’ve been following the advice above and seem to be working through many of my earlier issues trying to get Apple Mail and IPhone to work together with Gmail.

    Near the end of the iPhone instructions I’m a bit stumped by:

    Change your ‘Drafts Mailbox‘, ‘Sent Mailbox‘, and ‘Deleted Mailbox‘ settings to their respective folders in ‘[Gmail]‘, then change the ‘Remove‘ setting to ‘Never‘. Change the ‘IMAP Path Prefix‘ setting to ‘[Gmail]‘.

    When I tap on Drafts or any of the other three on my iPhone I get all kinds of possible choices and I honestly have no clue which are the correct ones. For example with “Drafts” there is “On my iPhone” Drafts, there is “on the server” Drafts, there is “On the server” Drafts (myemailaddress).

    Similar multiple choices for Sent and Deleted. Any help in knowing which is the correct choice would be appreciated.

    Thank you!

  15. I should add this to the above for clarity. If the instructions about “respective folders in [Gmail]” means what I am seeing on my iPhone… within the hierarchy under [Gmail] there is no choice for Drafts; for “Sent Mailbox” the closest choice is Sent Mail; and for “Deleted Mailbox” I’m guessing it must either be All Mail or Trash if this is to tie into the earlier instruction about setting up Apple Mail.

    Again, thanks for any help you can provide!

  16. Hey Larry

    The mailboxes on the iPhone vs. Gmail are:

    Drafts Mailbox: Drafts
    Sent Mailbox: Sent Mail
    Deleted Mailbox: All Mail

    I mention “All Mail” for the Deleted Mailbox instead of “Trash”, because Gmail gives you so much storage I find it’s handy to keep all your email for future reference. :)

  17. I have the same problem as Basil. Configured my account as IMAP, everything works.
    However: when I’m writing a mail to someone, it automatically saves it to the server every minute or so. When I finally send it, I see all these drafts in the Trash. I mean 10-15 drafts. Why does it do that?
    Now I have to empty my trash each time after I sent a message.

  18. Okay, I’m back. I’ve been using MobileMe but decided to let my account expire and switch back to Gmail. I just set up my Gmail account in Mail following your instructions. I think it’s working, for the most part, but there is one thing that really bugs me.

    Each time a message comes into my inbox, I also see an “unread” message appear in my Trash mailbox. I suspect this is because I have configured Mail to use Gmail’s All Mail folder as the Trash mailbox, as explained in your instructions. So a new message comes into my inbox AND into the Trash/All Mail folder – and shows up as “unread” in Trash, which clutters up the interface.

    If I disable All Mail using the advanced IMAP controls, that doesn’t help because then I can’t search my archived mail from within Mail.app (this is crucial for me). I also want to retain Gmail’s archiving feature, so that when I delete a message in Mail.app it goes into Gmail’s All Mail instead of being erased forever or stored only in the local Mail.app client.

    Is anyone else having this issue? Is there any way around it?

  19. Hi Chris

    Unfortunately, because of the way Gmail and the suggested configuration above works, what Apple Mail calls “Trash” is called “All Mail” by Gmail.

    Due to this the “Trash” folder will always display your unread message count. I suggested that the folder structure be configured this way to make use of Gmail’s “archive your emails forever” feature, and unfortunately I don’t think there’s a way you can get around it. :)

  20. perfect.. i’ve been reading a dozen sites giving instructions for this, yours is the most comprehensive one. Thanks!

  21. Hi there,

    Thanks for the tips.

    I didn’t apply the setup from scratch, I modified the setup I already had but something is weird.

    Everytime I send an e-mail (either from Mail or the Iphone) I receive it in my inbox as well.

    How can I avoid this?

    Thanks,

    Diego

  22. Neerav Kothari Reply 13 Dec 2009 at 12:20

    There is no option on my iPhone to set the Sent Mailbox behavior on my iPhone. I have successfully set Trash and Drafts. Any help?

    Neerav

  23. When I enter [Gmail] in the Mail Preferences Advanced tab, I get an error that says: “Unknown Mailbox: [Gmail]/[Gmail]/Trash (Failure)”

    Where did the duplicate [Gmail]/[Gmail] directory come from???

  24. I had originally set up mac mail without the [Gmail] value for “IMAP Path Prefix” and I was able to see all my labels, as well as seeing my inbox mail in Inbox/Gmail.

    Now that I changed it all I see is everything in “All Mail”.. and I see no labels folder. This doesn’t seem better. Any suggestions?

    My main issue with mac mail is that I was getting duplicates in the “all mail” folder of everything else.

  25. This entry was extremely helpful to me when I just migrated my small business email to google apps.

    Being able to have google spam filters and having my iPhone and desktop know which emails have been read is a time saver.

    Here’s a question: In the section of your post about configuring mailboxes in Mail, you say,
    “Click on the ‘Drafts‘ folder, choose the Mailbox menu item in the menubar at the top of the screen, then choose ‘Use This Mailbox For‘ -> ‘Drafts‘.”

    If I want to undo pointing a mailbox in Mail to a particular IMAP mailbox on gmail, how can I undo this?

    Your help is appreciated.

  26. Hi, thank you very much for the tutorial. I still have one problem though. I followed all the instructions, but I still get two copies of the sent mails, one in the sent mail folder and one in my Mail inbox. What can I do?

  27. Hi Francisco

    If sent mail is showing up in your Inbox, it sounds like the Inbox is set to display All Mail.

    Does this happen with all emails, or only some of them?

  28. Hi Willem,

    This seems like a brilliant solution — the default “sent mail” mailbox behaviour is inconvenient.

    In making the settings, my Apple Mail programs freezes when I try to save settings after changing the IMAP path prefix to [Gmail]. Do you have any ideas about what might cause this?

    Thx.

    Christopher

  29. Does it normaly take ages for the gmail window to appear on the mac mail window?

    • No, it should be there, even if you are online. The advantage of the imap service is that it is kept synced across multiple platforms (eg. delete it on the mac and it is no longer on your iphone, etc.) But all of the gmail mail should be visible and even stored on your mac. This means no hesitation when you open Mac Mail.

  30. Thanks! Finally worked with snow leopard mail.app (intel iMac)

    • I have configured my Apple Mail to my gmail BUT, since gmail has unlimited capacity I have not been deleting emails for like the 8 years that I have my gmail account. That’s millions of emails. When I open Apple Mail, it just starts taking all those mails in.
      Does anyone know how I can prevent this from happening and just start from a “blank slate” with my Apple Mail? (PS: I now have my gmail in Outlook, which does not have this problem)

      • Hi Sloane

        You can try the following:

        - Open Preferences (click Mail->Preferences or press Command-,).

        - Click on the “Accounts” tab.

        - Select your Gmail account from the list.

        - Click on the “Advanced” tab.

        - Set the “Keep copies of messages for offline viewing” dropdown to “Only messages I’ve read”.

        - Close the Preferences window and save your changes when prompted.

        Mail will now download the headers for all of your old messages and only download the full messages after you click on them to read them for the first time.

  31. I found this very useful, however I had to change the IMAP prefix from ‘[Gmail]‘ to ‘[Google Mail]‘, then everything worked smoothly.

  32. I’ve used the ‘All mail’ for my trash option, although the quirk I see is that emails that come into my inbox are also in my trash folder (I guess because inbox and trash emails are in ‘all mail’)?

    so if I do a search in my mac mail, I see the email appear twice – in my trash and inbox mailboxes.

    if I delete the email from the inbox, I get two duplicate emails in my trash folder.

    any ideas what is going wrong ?

  33. I have the same problem as Greg above. My question is:

    In the section of your post about configuring mailboxes in Mail, you say, “Click on the ‘Drafts‘ folder, choose the Mailbox menu item in the menubar at the top of the screen, then choose ‘Use This Mailbox For‘ -> ‘Drafts‘.”

    If I want to undo pointing a mailbox in Mail to a particular IMAP mailbox on gmail, how can I undo this?

    —- Why do I need to know this? I initially chose “Trash” to be used as “Trash”. I would much rather have “All mail” to be used as “Trash though, because I do not want my emails to be deleted on the server when I delete them in mail…. Please help me with this one.

    Thanks a lot!

Trackbacks/Pingbacks

  1. Gmail on Apple Mail at www.anthonysmith.me.uk - 03 Oct 2009

    [...] Hotmail … enough said!) I’m using Apple Mail on the Mac, and setup was easy, thanks to some helpful instructions on Geekology (I didn’t use the “IMAP Path Prefix” bit though). A few very minor issues (such [...]

  2. Jeff Schoolcraft (jschoolcraft) « Configure Gmail IMAP accounts properly in Apple Mail and on the iPh... « Chat Catcher - 19 Oct 2009

    [...] 2009-10-19T07:07:28 Configure Gmail IMAP accounts properly in Apple Mail and on the iPhone | Geekology [link to post] [...]

  3. John Kordyback (jkordyback) « Configure Gmail IMAP accounts properly in Apple Mail and on the iPh... « Chat Catcher - 26 Oct 2009

    [...] Configure Gmail IMAP accounts properly in Apple Mail and iPhone [link to post] [...]

  4. Adrian (orangea) « Configure Gmail IMAP accounts properly in Apple Mail and on the iPh... « Chat Catcher - 25 Dec 2009

    [...] 2009-12-24T21:29:44 Make Mail work well with Gmail (found by googleing): [link to post] [...]

  5. Fernando Almeida (fmalmeida) « Configure Gmail IMAP accounts properly in Apple Mail and on the iPh... « Chat Catcher - 18 Jan 2010

    [...] 2010-01-18T07:33:07  Great tutorial for nicely setting up Mail Mac OS client with gmail. [link to post] [...]

  6. How to tame your (new) Mac » How to train Mail.app to use Gmail properly - 03 Apr 2010

    [...] The internet is full of good advise on how to use Apple’s Mail with Gmail and IMAP. Two of them helped me to find my optimal solution (thanks to Joel & Willem). [...]

Afrigator