Finally! A clean config for Gmail IMAP, Mail, and the iPhone

Noah has posted a clear and concise HOWTO for getting GMail IMAP to work consistently between Mail and the iPhone. There are many, many tutorials on how to do this but none get it quite right if you are trying to sync an iPhone and with GMail accounts. I was constantly having problems where mail deleted on my iPhone would not be deleted in Mail. Problems solved. This tutorial should work equally well for iPod Touch users.