Why not use an e-mail script that's already been done? I've never used them, but I assume there are some decent ones out there.
Beyond that, do you have your socket script started? If so, post it (minus login info... change those to XXXXX's or else variables) and we can see if there are any obvious errors.