Mine is unlocked so haven't had to try. If you still have a t-mobile account, I'd suggest calling them for the unlock code. They should give it to you for free if you're on contract or pretty cheap if you're on PAYG. O2 did it for me when I had an iPhone. It's done properly that way.
If you bought the phone from someone, you might want them to call t-mobile for you. They should only need the model and IMEI no.