I recently switched to Gmail since they started offering IMAP. As many of you know, the Gmail IMAP implementation is not without issue, especially when using Mail.app. A lot of this is due to the fact that Mail.app won't subscribe to Gmail folders. Issues arise, especially with copies of emails always remaining unread in the "All Mail" folder even if you already read them in your inbox. This annoyed me, so I looked for a workaround.
I first tried This one, but it didn't completely solve my issues. And I also found that Mail.app 3.2 (in Leopard) didn't always play nicely with Gmail's IMAP (at least on my machine).
So, I made a combined approach that works well. I outline the steps below. I got my ideas from www.macosxhints.com as well as my own trial and error.
In gmail.com, make the following labels (or any labels you like as long as you have a forward slash in them (Mail.app treats labels as folders):
IMAP/Sent
IMAP/Trash
Then, setup the following filter in Gmail:
messages from your email address are applied to label IMAP/Sent. This will make sure that if you ever send mail from the web-based email editor, it will also show up in your Mail.app sent folder.
Then, in Mail.app, make a Gmail IMAP account. Don't let it automatically setup. That will make a POP account. Do it manually to get IMAP.
My next steps go against Gmail's own published guidelines. I have tried them without any problems.
Under preferences--accounts--mailbox behaviors, make sure you uncheck "save drafts on server." (I noticed that when you type new messages, Mail.app and Gmail combine to make incremental copies of each message, so after you send it, you have 4 or more partial copies of the message in your trash folder. That's too messy for me).
Next, check on "store sent messages on server" (select your preferred deletion interval--I have 1 week) and "move deleted messages to trash folder" and "store deleted messages on server" (select your deletion interval--mine is 1 week).
Then, under the advanced tab, set IMAP prefix path to IMAP (this ties back to the labels you previously made).
Then, using methods similar this method described above, map your sent and trash folders. You'll see your IMAP/Sent and IMAP/Trash folders in Mail.app's sidebar.
Note, that when you move messages to you Mail.app trash folder, you're not actually deleting them, but only getting them out of your inbox. They will always remain in your All Mail folder and will not be moved to Gmail's Trash folder.
Sure, this creates duplicate copies of all sent and trash messages, but if you select a deletion increment from within Mail.app, they will disappear. You'll have a nice permanent archive of all sent messages in the Gmail default Sent folder and All Mail folder, which is the whole idea behind Gmail to begin with. You'll get the same effect when using POP in Gmail, but my setup allows you to sync your mail with IMAP, which is the whole allure of IMAP to begin with.
I have not noticed any bad effects of this setup yet. Deleting a single message from within Mail.app, and it's subsequent automatic deletion from the sent and trash folders, does not delete the entire conversation that can happen when you delete messages from within Gmail's web editor. If you permanently delete one message of a conversation from within Mail.app, the whole conversation will remain in Gmail's All Mail. Once you delete the entire conversation from within Mail.app, the entire conversation will remain in All Mail but will not have any traces in the Inbox.
This works well for me and I wanted to share. Try it out and see if it works for you.
EDIT: I noticed two new things. First, apparently Gmail supports Idle Commands (push mail). Secondly, Mail.app's communication with the Gmail server using Idle Commands isn't a perfect match, so it's probably best if you disabled use Idle Commands from within Mail.app
I first tried This one, but it didn't completely solve my issues. And I also found that Mail.app 3.2 (in Leopard) didn't always play nicely with Gmail's IMAP (at least on my machine).
So, I made a combined approach that works well. I outline the steps below. I got my ideas from www.macosxhints.com as well as my own trial and error.
In gmail.com, make the following labels (or any labels you like as long as you have a forward slash in them (Mail.app treats labels as folders):
IMAP/Sent
IMAP/Trash
Then, setup the following filter in Gmail:
messages from your email address are applied to label IMAP/Sent. This will make sure that if you ever send mail from the web-based email editor, it will also show up in your Mail.app sent folder.
Then, in Mail.app, make a Gmail IMAP account. Don't let it automatically setup. That will make a POP account. Do it manually to get IMAP.
My next steps go against Gmail's own published guidelines. I have tried them without any problems.
Under preferences--accounts--mailbox behaviors, make sure you uncheck "save drafts on server." (I noticed that when you type new messages, Mail.app and Gmail combine to make incremental copies of each message, so after you send it, you have 4 or more partial copies of the message in your trash folder. That's too messy for me).
Next, check on "store sent messages on server" (select your preferred deletion interval--I have 1 week) and "move deleted messages to trash folder" and "store deleted messages on server" (select your deletion interval--mine is 1 week).
Then, under the advanced tab, set IMAP prefix path to IMAP (this ties back to the labels you previously made).
Then, using methods similar this method described above, map your sent and trash folders. You'll see your IMAP/Sent and IMAP/Trash folders in Mail.app's sidebar.
Note, that when you move messages to you Mail.app trash folder, you're not actually deleting them, but only getting them out of your inbox. They will always remain in your All Mail folder and will not be moved to Gmail's Trash folder.
Sure, this creates duplicate copies of all sent and trash messages, but if you select a deletion increment from within Mail.app, they will disappear. You'll have a nice permanent archive of all sent messages in the Gmail default Sent folder and All Mail folder, which is the whole idea behind Gmail to begin with. You'll get the same effect when using POP in Gmail, but my setup allows you to sync your mail with IMAP, which is the whole allure of IMAP to begin with.
I have not noticed any bad effects of this setup yet. Deleting a single message from within Mail.app, and it's subsequent automatic deletion from the sent and trash folders, does not delete the entire conversation that can happen when you delete messages from within Gmail's web editor. If you permanently delete one message of a conversation from within Mail.app, the whole conversation will remain in Gmail's All Mail. Once you delete the entire conversation from within Mail.app, the entire conversation will remain in All Mail but will not have any traces in the Inbox.
This works well for me and I wanted to share. Try it out and see if it works for you.
EDIT: I noticed two new things. First, apparently Gmail supports Idle Commands (push mail). Secondly, Mail.app's communication with the Gmail server using Idle Commands isn't a perfect match, so it's probably best if you disabled use Idle Commands from within Mail.app