Configuring Mail.app and iPhone with Google IMAP

So I recently moved almost all of my personal e-mail domains over to Google Apps. A couple of people have asked, “Why?” My answer is simple: it’s easier. The e-mail functionality of my current hosting provider is lacking in a couple of key areas:

  • Rather than using the emerging standard of having e-mail clients connect to TCP port 587 (Submission) to send e-mail, they used a very non-standard practice of using TCP port 26. (Now if we could just get older versions of Outlook to not have a severely broken SMTP client implementation, we’d be in good shape. But that’s another story…)
  • Despite paying for a dedicated IP address, I can’t use my own SSL certificates for e-mail (only web traffic). The SSL certificates the hosting provider supplies for e-mail are self-signed certificates and cause fits to clients such as Outlook and Mac’s Mail.app.

By using Gmail and/or Google Apps, on the other hand, these issues go away. However, Google’s particular implementation of IMAP—and its use of labels vs. folders—presents a few challenges of its own. During the process of migrating over to Google Apps and using IMAP for all my e-mail accounts, I have finally settled into a configuration that works well for managing e-mail from my MacBook Pro as well as my iPhone.

The secret lies in a Google Labs feature called “Advanced IMAP Controls.” By enabling Advanced IMAP Controls, Google Apps and Gmail users can control which labels will appear in Mail.app (and other IMAP clients, like the iPhone). Here’s the configuration I’ve been using that seems to work really well:

  1. In the Mail section of Google Apps or Gmail, go to Settings, then Labs, and enable “Advanced IMAP Controls”. Google Apps users may need their administrator (if they don’t have administrative permissions) to allow Labs features to appear. I’m not sure about Gmail users; I think Labs features are available by default for Gmail users.
  2. Once Advanced IMAP Controls are enabled, go to the “Labels” section of Settings and uncheck all labels except Drafts, Spam, and Trash.
  3. When setting up Mail.app, configure the IMAP account as normal, but set the Inbox Path Prefix to “[Gmail]“. When you take the account online, a heading for that account should appear in the Mail.app sidebar with three folders under it: Drafts, Trash, and Spam.
  4. Select the Drafts folder/label under the account’s heading, then go to Mailbox > Use This Mailbox For > Drafts. This should cause the Drafts folder under the account’s heading to disappear. Instead, it will be listed under the unified Drafts folder under the Mailboxes heading.
  5. Repeat the process for the Trash folder/label (use for Trash) and Spam folder/label (use for Junk). After performing this process on all three folders/labels, the account heading should disappear from Mail.app’s sidebar.
  6. In the Mailbox Behaviors section of the account settings (Under Mail > Preferences) check the box for “Store draft messages on the server.”
  7. In the same area, also check “Store junk messages on the server” and specify a time period for how long to keep junk messages.
  8. Finally, check the box for “Move deleted messages to the Trash mailbox” and “Store deleted messages on the server” and specify how long to keep deleted messages.

To keep mail synchronized between the IMAP server, Mail.app on my laptop, and Mail on my iPhone, I replicated these settings on my iPhone, selecting the Drafts folder/label as the “Drafts Mailbox” and the Trash folder/label as the “Deleted Mailbox” in the Advanced area of Mail settings.

With this configuration, reading a message on my laptop will mark it as read on my iPhone, and deleting a message on my iPhone will make it appear in the Trash mailbox on my laptop. In addition, I can continue to leverage Gmail/Google App’s web interface when necessary as well, and see draft messages and deleted messages in the appropriate areas there, too. All in all, it works very well for me.

If you have other tips for enhancing the use of Gmail/Google Apps with Mail.app and your iPhone, I’d love to hear them in the comments below. Thanks!

Tags: , ,

  1. Josh’s avatar

    How do you deal with labels and archiving then? Do you not use any of that?
    If I uncheck “All Mail” from showing up in IMAP, I can’t readily archive a message from mail.app OR the iphone.

  2. slowe’s avatar

    For long-term storage of messages, I do that locally on my laptop. I generally don’t keep extensive amounts of mail on the server.

    However, it seems to me that Google puts all the mail into “All Mail” anyway, even messages that I’ve “archived” into a local mailbox. You can’t see the “All Mail” label from Mail.app or the iPhone, but Google continues to use it. Has that not been your experience?

  3. Stephen Foskett’s avatar

    IF you set the [Gmail] prefix, you won’t be able to see any of your labels as IMAP folders. This can be a good or a bad thing depending on your perspective!

    Google defaults to automatically archiving any message without an imap-visible folder/label. So when you “delete” over IMAP, it just removes a label. Assuming that message isn’t otherwise labeled with something visible to IMAP, the message remains as-is but is removed from the IMAP Inbox. You can change this behavior on the IMAP settings tab.

    This decidedly cleans up the inbox in Mail!

    Note too that the iPhone allows you to set the [Gmail] prefix in Advanced settings so you can clean it up too!

  4. Stephen Foskett’s avatar

    On second thought… There is kind of a problem here. iPhone delete (in 2.0+) moves mail to Trash, where it will be permanently deleted after 30 days. This is kind of anti-gmail! To get around this, you also need to enable [Gmail]/All Mail in the Labels settings and then you need to set the iPhone to delete to All Mail on the phone. I’ll document this on my blog soon!

  5. slowe’s avatar

    I forgot to mention to set the path prefix to “[Gmail]” on the iPhone as well; good catch!

    As for the deleted messages, couldn’t you just set (both on the Mac and on the iPhone) to never delete messages in Trash? This would accomplish the same thing. Further, I’ve read lots of references to not having IMAP clients try to delete out of “All Mail” because it will cause errors. I’ll have to keep experimenting with this.

    Thanks, Stephen!

  6. Josh’s avatar

    Ah yes, I had forgotten how “All Mail” works. However, I utilize a lot of rules within Gmail to send messages to various labels, so I don’t know if I can get away with turning off all the labels.

  7. slowe’s avatar

    Josh,

    Certainly if you need to maintain/use the other labels, then leave them checked in the settings. Also, you may find that you can’t use the “[Gmail]” Inbox path prefix, as I believe that messes around with custom labels. If you want to use custom labels and also take advantage of hiding some labels, I think you need to re-create them as “[Gmail]/Label” instead. I could be wrong, though…

  8. Felix’s avatar

    Thx for the tip regarding how to remap folders in Mail.app, I’ve been dying to have that for a long time, but never looked in the Mailbox menu. It’s really great with my German GMX account aswell, because it uses German folder names which of course mismatch the default neglish names used by Mail.app.

  9. Matt Warren’s avatar

    Anyone see the issue where mail read on the iPhone never updates to read status for other clients? I’m using gmail site and Entourage (12.5) and message always show as unread when the iPhone shows them as read.

  10. Sean Hoyt’s avatar

    I found this article specifically because I’ve noticed, and am annoyed by, the fact that reading email on the iphone doesn’t update the read status in mail.app. How the heck to we get that to work?

  11. slowe’s avatar

    I have noticed the same thing, but I haven’t yet figured out exactly how to remedy that. I’ll post something here when I get it resolved.

  12. Mat’s avatar

    I’m damn glad I found this blog !
    Thx for cleaning up my Mail.app and iPhone :)