These are instructions on how to unlock the iPhone 4, iPhone 3GS, and iPhone 3G for use with any GSM cellphone carrier using UltraSn0w. This will work with the iOS 4.2.1 firmware if you are on the 06.15.00 baseband.
Before you can follow these instructions you must have a jailbroken iPhone and you must be on the 04.26.08, 05.11.07, 05.12.01, 05.13.04, 06.15.00, or 01.59 baseband(modem firmware).
To find your firmware and modem firmware(baseband) versions you can follow this tutorial.
If you are on T-Mobile remember to turn off 3G before starting...