To add your Gmail account to Mail.app, first launch the app, and (if it does not prompt you to add an account), go to Preferences, click on “Accounts” and then click on the “+” at the bottom-left corner.
This image also shows you an example of what a completed account set up for Gmail looks like.
Mail.app will show you various options for different mail services. Choose “Google” from this list:
Click continue, and you will be asked to enter your Gmail username (email address) and password.
Click “Sign In”
If you are using two-factor authentication, enter the appropriate code here. (You are using two-factor authentication, right? Because your email is one of your most valuable online accounts, and you should do everything you can to protect it.)
Next, Google will tell you what “OS X” wants to be allowed to do:
Click the “Accept” button (note: the button will be greyed out when the window first loads, but should become active after a few seconds).
Last but absolutely not least, select the “apps” that you want to use your Google account. If you will be using your Google Calendar, be sure to check that box as well.
Once you’ve done those steps, Mail.app should be automatically configured to send and receive email from your Gmail account.
Gmail Pro-Tip: Limit IMAP folder sizes
If you are in the habit of keeping a lot of email, you may find that Mail.app will eventually get very slow trying to keep up. This is especially true because of the “All Mail” folder. Gmail has a way to help with this, by allowing you to automatically limit the number of emails which will be shown in IMAP (that is, in your Mac or PC or iOS or Android mail client). You can limit it to the most recent 1,000, 2,000, 5,000, or 10,000 messages.
Older messages will not be deleted but will simply not show up in your regular mail app. To see them, you will have to go to Gmail.com and use the web interface.
Based on my previous experience, I would not recommend anything over 5,000 messages, and would suggest 1,000 or 2,000 at the most.
To find this setting, log into Gmail.com, click on the “Gear” icon, and then click on “Settings”:
Next, select “Forwarding and IMAP" as shown here:
Then scroll down until you see the “Folder Size Limits” setting. It is Off by default, so you will have click the radio button next to “Limit” and then choose the number from the dropdown box, as shown:
“Delete or Archive?”
Setting up a Gmail account used to be somewhat confusing because when you would “Delete” an email, Gmail assumed that what you meant was that you wanted to keep it in the “All Mail” folder. That is no longer the case. Any message that you delete via Mail.app will be sent to the “Trash” folder/label in Gmail, where it will be automatically deleted after 30 days.
For best performance, I recommend moving read email out of your Inbox, either by deleting it or Archiving it. Mail.app has an “Archive” menu item:
You can also trigger the “Archive” command using Command+Control+A which will help you get through your Inbox quickly.