Update: This post relates to iOS 6 and Mac OSX 10.8 for iOS7 and OX 10.9 look at my newer post.

Maybe I’m not the only one who wants to have a correct Mail.app setup for GMail.

If you setup a GMail account in Mail.app everything works, but not optimal. You get an akward grey [Gmail] folder (differs in some countries) with some subfolders in Mail.app. When you delete a message it will be kept in a All Mail folder and that folder contains every mail in all other folders you have. So Mail.app stores all your Mail at least twice internally.

Reason for that is, that GMail internally uses labels instead of folders and that setup does not play well with the normal Mac Setup.

There is a way to setup Mail.app to play with GMail, and here is how:

Log in to GMail via web and go under settings to “Forwarding and POP/IMAP”. Change the default _ Auto-Expunge on_ to off and the When a message is marked as deleted and expunged from the last visible IMAP folder: to Move the message to the Trash and save that.

The important thing here is a litlle remark last visible IMAP folder as we will check off the default IMAP visiblity for All Mail in the setttings for Labels next.

Label settings in GMail

Forwarding settings in GMail

Before you continue, make sure that all your own labels in GMail have a [Gmail]/ prefix.

In Mail.app change the IMAP Prefix to [GMail]: Setting Gmail prefix in Mail.app

Disable Junk filtering in Mail.app (Google does that) Disableing Spam filter in Mail.app

And while you are at it, change in the outgoing mail server settings the port number from default to 587. This will use authorized sending of mail and will keep you from getting headaches when you are in a hotel and Mail can’t send mail as port 25 is only half blocked.

Setting port 587 in Mail.app

Now Mail.app should work fine with GMail. You can Archive Mail, delete mail and won’t have cluttered your disk with every mail twice.

Remark: I used US-English settings on GMail and on the Mac. If you have different language settings it might be that you have tell Mail.app via the Mail->Mailbox->Use this mailbox for menu the correct location for Trash and Sent Mail.

For some [Gmail] is in fact [Google Mail].

Remark2: If you are using a iOS device, make sure to uncheck the ‘Archive Messages’. By unchecking you will get a correctly labeled ‘Delete Message’ button when swiping over a message.

Otherwise the same button would be labled ‘Archive Message’ and in fact move the message to Trash.

Uncheck Archive Messages on iOS