It's simple and this is how I always do it.
1. Sync with iTunes remove all music, apps, books,photos etc.
1.1 If you have any photos in the camera roll that you want import into iPhoto or whichever photo app you use and then delete them from phone.
2. Manually go in and delete any mail accounts.
3.Clear call logs and text messages
4. Open safari close all tabs, then go to settings > safari> clear history, cookies, cache. Go to autofill and clear it if you have anything in it.
5. Settings > Store> click on your apple id and sign out.
6. Settings > General > reset all settings and then I erase all content and settings (but if you're jailbroken these usually just put the phone into a loop)
Hope this helps.