Specifically in connection to the gmail servers, I had significantly more luck a few months back when I wrote an automailer using Net::SMTP::TLS - the final code is published here.
Comment on Re^3: How to enable SSL support in sockets connected with a sock5 server?