Use port 587 instead of port 465 with SSL enabled.
The somewhat subtle difference is support for SSL/TLS is generally over port 465 while support for SMTP STARTTLS is generally over port 587. Using port 465 with SSL/TLS is technically supposed to be deprecated for SMTP in favor of STARTTLS but sufficiently many e-mail clients rely on port 465 that most mailservers support both. You can read more on the distinctions here.
It seems that in the specific case of GMail, both ports should support encrypted communication but port 465 does not work for everyone, though this might be related to encryption methods enabled on the machine. I can't use GMail with port 465 either on my machine, but haven't looked too deeply into why.