So, you just upgraded to Mac OS X Leopard and all its shiny new features including Mail (version 3). And you finally managed to integrate your GMail account using IMAP (woot!) into Mail. But what bothers you is the fact that when you delete mails, they still show up in the All Mails folder on the GMail web interface because they’re actually only marked as read and archived, not deleted.
Once you set up your GMail IMAP account correctly, make sure to check the “Move deleted messages to the Trash mailbox” and the “Store deleted messages on the server” checkboxes. If you want to, you may also set an expiration date for deleted mails but as GMail deletes messages in the Trash folder after 30 days, I left this option unchanged. After you close this window, navigate to your GMail mailbox in the left window pane of Mail.app.
You’ll find all your regular IMAP folders (All Mail, Sent, etc.) there as well as a list of the tags (a.k.a. labels) you’re currently using. You wonder why Trash doesn’t show up in my list? Well, I already set it up correctly, so the folder disappears from this list and appears aside of all other Trash folders.
You just have to perform a control-click (yes, you may also use your right mouse button) on the Trash folder and select “Use this folder for deleted messages” from the pop-up window.1 That’s it! From now on, your deleted messages are moved to GMail’s Trash folder and automagically cleaned up by GMail.