When you plug it into the iMac go into iTunes and click on the iPhone.
Select playlists etc etc that you want to sync then hit apply, it should tell you that the iPhone is already paired (or something) with another Mac, and you can erase and sync with this new one.
If it doesn't then, I;m at a loss.