Before selling your iPhone on eBay, sending it to Apple, or otherwise sharing it, note the following: performing a "Restore" operation on the iPhone does not delete personal data from the device. In fact, mail, contacts, and various other data remain intact on the device after a restore, making the process unsuitable as a preparatory measure for iPhone resale or service.
Jonathan "NerveGas" Zdziarski, iPhone hacker and author of the "iPhone Open Application Development" and an iPhone Forensics Manual for Law Enforcement, has recently posted noted in his blog
"As part of my work on a forensics toolkit for the iPhone, I decided to push my test device to the limits and see whether user data could survive a full restore in iTunes. [...] I first deleted any backups of my device and then forced the iPhone into recovery mode. From there, I performed a full restore of my iPhone, ensuring that no backups or syncing was performed. I then performed a basic recovery of the raw disk using the forensic toolkit I put together, and analyzed it. What I discovered was that deleted mail, contacts, and pretty much all of my other personal information was still residing in unallocated space on the device. My personal information safe and sound, and available to anyone with the right skills to recover it."
"What does this mean? This means that when you do a restore through iTunes, it is only the equivalent of performing a 'Quick Format' on your iPhone. All of the personal information that was sitting on the device prior to the restore is still accessible in the unallocated blocks of the iPhone's NAND memory. To make matters worse, the restore process is likely to restore the original operating system files over the same location as the old ones, meaning very little data is likely to be corrupted at all. Let this be a caution to everyone who sells used iPhones on eBay (or elsewhere) - you are selling your personal data with it."
We aren't aware of any clean sweep process that is capable of deleting personal data on the iPhone. Your best bet is to manually delete such data before performing a restore and reselling or servicing the device. Private data stored on the NAND will still be viewable by prying eyes, however.