How to clear/wipe an Android phone before selling it? I have two phones, the LG GT540 optimus and Samsung GT-i5800, both using Android 2.1, and I intend to sell them in the near future.

Before selling (just like before selling a HDD), I want to wipe all the personal DATA from the phones. 

Question:
Does a "factory reset" (from the Android phones "menu") surely wipe all the personal data? Or will there be something left to use? (ex.: contact list, Gmail password, etc.?)
By doing a factory reset and formatting the SD cards, I would say that it is safe enough to sell. If you want to be perfectly sure, flashing the original ROM with option of wiping the cache will make the phone as good as you got it when you purchased. Of course, still you have to format the SD card in that case as well.

To know how to flash the original ROM for you LG Optimus GT540, you can visit this page, which has a step by step instructions about this process.  You should be able to find similar such page for your other Samsung device just with Google search.

Update: I found this web page, which explains about to how to downgrade i5800 to 2.1. By that process you can get the original ROM (watch out for the region) and safely sell.