I recently unlocked my Nokia 5310 XpressMusic phone that I am using with T-Mobile and thought I would post some instructions for the unlock process. If you have been on a contract with T-Mobile for a certain amount of time (at least 3 months I think but it could vary based on phone), you can call T-Mobile and get an unlock code emailed to you within 1 to 7 days. It took less than a day for me.
I received an unlock code and the following instructions from T-Mobile:
Pay special attention to the note above about your phone getting permanently locked if too many incorrect attempts are made to unlock the phone.