I\'ve been trying for a whlie on this, and have so far been failing miserably. My most recent attempt was lifted from this stack code here: Sending email through Gmail SMT
I tried your code, and it works prefectly with port 587, but not with 465.
Have you checked the fire wall? Try from the command line "Telnet smtp.gmail.com 587"
If you get "220 mx.google.com ESMTP...." back, then the port is open. If not, it is something that blocks you call.