How can I mechanically secure a headphone cable after soldering on a new connector?
I find that cyanoacrylate glue (Krazy Glue, Super Glue) works well for securing cables in strain releifs,

Ideally I push the cable into the plug too far, glue the bit that sticks in and then pull it back to the correct location.