Update 8/2/2010: If you're using iPhone OS 4 or newer, archiving in Gmail will work once you go through the standard mail set up — no need to follow these instructions.

Pretty much everyone with an iPhone and a Gmail account has a preference for how to use the two together. Some people prefer the iPhone's built-in email client -- it's fast, syncs everything via IMAP, and works like the rest of the device. Others, myself included, can't live without search and threaded conversations and prefer to bring up Gmail in the browser. And a few people, for whom this tip is geared, read their mail via the client but switch to the browser-based version to clean out their inboxes so they can easily archive rather than delete.

See, the default Gmail set up for iPhone's built-in mail client configures things such that if you delete a message on your iPhone, it's sent to Gmail's Trash. That means in 30 days it's gone forever. Sure, you can archive by clicking the "Move to" button and then selecting "All Mail," but if you're an archive junkie and want mail you delete on your iPhone to get archived in Gmail instead, you just have to re-do the Gmail set up on your phone.

First, get rid of your default set up. Go to Settings > Mail, Contacts, Calendar. Find your Gmail account under "Accounts," click on it, scroll to the bottom, and click "Delete Account." Don't worry -- it'll be back and better than ever in a sec.

Then manually configure IMAP using the "Other" menu option by following the instructions this video (also available in the Gmail Help Center):

From then on, the iPhone's little trashcan icon will archive your mail. You might notice that messages you archive on your phone are actually being added to a new "Deleted Messages" label in your Gmail account -- but they're right in "All Mail" and searchable, just the way you want them.