As of the Mountain Lion version, Apple’s Mail is better than ever at helping you manage your email. And Google’s Web-based Gmail is also pretty good—but how do you combine the two in just the right way so as to get the best of both?
The answer is simple—follow my guide below, wherein I describe my favorite way to balance a few features and compromises to make Mail and OS X work best with the Gmail Way.
Step 1: Enable IMAP
The first step to getting OS X’s Mail to work well with Gmail is to enable IMAP access. This will not only let Mail check your Gmail messages, but also keep everything in sync between your devices and the Web.
Log in to Gmail in a desktop Web browser, and click the gear icon on the right of the page, just below your Google Account avatar. In the menu that appears, choose Settings. Click the Forwarding and POP/IMAP tab. About halfway down the page in the IMAP Access section, select Enable IMAP. Click Save at the bottom of the page.

Step 2: Tweak labels in Gmail
When you use Gmail on the Web, you can take advantage of a few unique features that traditional email clients like Mail don’t support. The biggest example: Gmail labels. Instead of filing messages into single folders, as Mail and most other clients do, Gmail lets you tag email messages with multiple words, or labels, just as you can with photos on Flickr.

To ensure a smooth multidevice ride, stay in Gmail’s settings and click the Labels tab. Here, you make labels invisible to apps that can’t deal with them, such as Mail on your Mac, iPhone, or iPad. Two such labels are “Chats” and “Important,” so in the Labels tab, ensure that the Show in IMAP checkbox is disabled for them. However, unlike previous advice, make sure All Mail is enabled.
One note: With All Mail enabled, Mail will keep multiple copies of your labeled messages. Mail now hides the copies, so you won’t be bothered by them, but the copies do take up disk space. It’s a compromise, to be sure, made to adapt Mail to the way Gmail works. But I think the compromise is worthwhile.
Step 3: Add your Google account to OS X
Before OS X Lion, when you wanted to add your Gmail account, you’d do so in the Mail app by selecting Mail > Preferences > Accounts. You can still do that if you want, but OS X now understands more about your Google Account—that it includes not only Gmail but also other services. So I recommend instead opening System Preferences and selecting Mail, Contacts, & Calendars. (Yep, this deja vu is brought to you by iOS.)

To add your Google Account here, click the plus button in the lower left, then click Gmail in the list of new account options on the right. Whether you’re using a regular @gmail account or Google Apps to run your Gmail through your domain (so your address looks like [you]@davidchartier.com), add your name, email address, and password on the sheet that appears, and click Set Up.
OS X will check with Google’s servers and then display a sheet offering all the apps you can use with your Google account. As of this writing, those include email, calendar, Messages (via the Google Talk services), and Notes. All will be checked by default, so feel free to disable any you don’t want.
If you do want to use some of your other Google Account services in OS X, though, this is a great way to make the magic happen.

Step 4: Set up Mail
Apple has made some strides when it comes to making Mail behave better with Gmail, but this working relationship still has a few catches.
Deal with archiving issues: One of Gmail’s perks is a ridiculous amount of storage space, so Google has set it up to highly encourage archiving your email instead of having to make the decision to delete just some of it. After all, you never know if that rainy day will come next month or four years from now, and there’s no harm in keeping tiny emails around in this age of ever-expanding storage space.

As of OS X 10.7 and 10.8, you might notice a new Message > Archive option in Mail’s menu. You can also use View > Customize Toolbar to add an Archive button to the toolbars of Mail’s main window and individual message viewer windows. Unfortunately, after two years and a number of bug reports filed with Apple, that button still doesn’t work properly with Gmail.
Press the button, and it will create a new top-level folder called Archive where you can now store messages that you don’t need in your Inbox, but that you want to be able to search later. This does not follow Gmail’s behavior on the Web of moving messages to All Mail, which means that messages archived through Mail won’t be stored in the place Gmail understands.
If you rarely sign into Gmail on the Web, you don’t need to worry about this. But if you do—say, while on vacation away from your devices or using a different work computer—some of Gmail’s built-in archive and search features won’t know to look in the Archive folder that Mail created.
Since you can’t fix Mail’s archive behavior with Gmail accounts, and you can’t tell Gmail to archive in a different folder, I propose a compromise. In Gmail’s settings, under the Forwarding and POP/IMAP tab, change the setting When I mark a message in IMAP as deleted to Auto-Expunge off. Then, just below that option, change the setting When a message is marked as deleted and expunged to Archive the message. Click Save at the bottom of the page. Once you tweak settings in Mail in a later step, using the Delete key on a message will tell Gmail to archive it in All Mail. If you truly want to delete a message, you can drag and drop it to the [Gmail]/Trash folder.
Tweak your labels: In the past, if you applied multiple Gmail labels to a message in your inbox, then searched for that message in Mail, you’d be flooded with duplicate messages—one for each label, another for its appearance in the inbox, and another for its All Mail entry. But happily those days are over. Now, Mail is smart enough to map Gmail labels to different folders. For example, if you’re on an email list for a hobby or your kid’s sports team, you can apply a Gmail label for “T-ball” as well as a second label of “Follow Up” for messages that you can’t deal with right this moment. The message will appear with both labels on the Web, or in two different folders—T-ball and Follow Up—in Mail. (Tip: to use multiple labels, or folders, in Mail, right-click a message and choose Copy To instead of Move To).
Better yet, when you search in Mail, it will show one single message from All Mail (not all the copies in different folders), unless you use the search tools that appear just below the toolbar to focus your search in a specific folder.
Once you open Mail, the new Google Account that you added to System Preferences should spring into action and download your inbox and labels/folders. To make everything work as well as possible, I recommend going to Mail > Preferences > Accounts and adjusting a few settings.
Click your new Google Account in Mail’s preferences, then click the Mailbox Behaviors tab. To keep this simple, uncheck everything so that Store draft messages on the server is the only thing enabled. Close the Preferences window, which will ask you to save your changes. Click Save; now you’re almost done!

To ensure that you can draft messages across devices, the last thing to do is tell Mail which Gmail folder to use for your drafts. In Mail’s main folder list on the left, find your Gmail account and click the arrow next to the top-most folder in it, called “[Gmail]” (yes, with the brackets). Click its subfolder called “Drafts,” then go to the menu bar and choose Mailbox > Use This Mailbox For > Drafts. The folder will disappear from under the [Gmail] folder in your sidebar and move up to the main “Drafts” heading at the very top of all your folders and accounts in the sidebar, under the heading “Mailboxes.” This way, Mail will save your drafts in the proper place it understands, but the drafts will also be properly synced with Gmail and your other devices.
Now you’re ready to Gmail. In Mail.
There you have it. Google made some changes in the past couple of years, and so did Apple. It still takes some finagling, but it’s now a little easier to get Gmail, and the rest of your Google Account, to work well with Mail and OS X.