If you've tried using Gmail on an iPhone you've probably been frustrated. Copies of sent and received emails end up in your inbox and read emails aren't synced to the server, so if left unchecked the number of unread emails in the Gmail boxes on your iPhone grows rapidly.
The problems stem from the fact that Gmail has been using the POP (Post Office Protocol) for accessing email outside of their Web client and POP is lame if you check the same email account on multiple devices.
IMAP (Internet Message Access Protocol) is the new kid in town and once you've mastered it, there's simply no going back. The great news is that some time last night Google gave some of their Gmail users the ability to access their email via IMAP.
The first thing that you have to do is enable IMAP for your Gmail account(s). Next you have to configure IMAP for your iPhone. Hint: Tap Other when setting up Gmail/IMAP on iPhone. If you tap Gmail, you'll set up POP rather than IMAP. Google is aware of the issue and is "currently working to make setting up Gmail more intuitive for the iPhone."
Update: Of the four Gmail accounts that I use regularly none of them allow me to see the IMAP option in settings. Perhaps Google is rolling out the IMAP upgrade in phases?
Update 2: In order to ensure your Trashed, Sent, Drafts, and Junk mail messages are sorted properly between your iPhone, Apple Mail, and Gmail’s webmail interface you should follow the instructions posted on 5thirtyone.com.