OK, I tried multiple things and found the following works for me:
First you need to root your phone (see the entry on rooting in this very forum). All you need is to get the update.zip file (attached here), copy it to your phone and restart while holding the volume buttons, and select "re-install packages". That will root your phone. Note that the attached Update.zip was edited by yours truly because the ones on the Internet don't work (they don't have the I897 in the assert statement).
Once the phone is rooted, install Terminal Emulator (an app in the market) and enter the following commands:
su
busybox grep -E "^[0-9]{8}$" /efs/nv_data.bin
The first command puts you in super-user mode. The second command searches the file "nv_data.bin" for an 8-character string consisting of only digits. That command should give you your unlock code (an 8-digit code).
That's it. I have a friend who has T-Mobile, and I borrowed his sim card from his phone. I put it in my phone and rebooted. After a few seconds after booting, my phone asked for the unlock code. I entered the number I got from the command above and it connected to the T-Mobile network successfully. I made a phone call and it worked. A couple of things though:
1- It only connects to the Edge network. The Captivate cannot use T-Mobile's 3G network, so it may be slower than AT&T when it comes to browsing the Internet outside of your WiFi zone. That's acceptable to me. AT&T's 3G network sucks anyway.
2- The phone will say that it failed to log in to your GMail account. Just click on the notification and enter your GMail password and that takes care of it.
I couldn't test it extensively because he wanted his sim card back, but I will be going to the T-Mobile store soon to switch and get my own sim card.
P.S. My phone is on update JH7, stock ROM. I don't know if this would work for any other version or any other ROM.