title: Swiftmailer Gmail Connection timed out #110
body: <p>I want to send emails using gmail's smtp with the PHP script posted below using Swiftmailer. Now this works fine on my own webserver. But when I used it on the webserver of the people I'm creating this for, I get an exception:</p>
  
  <pre><code>    Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection timed out #110]' in ...
  </code></pre>
  
  <p>What could be the problem? 
  I'm assuming its got to do with the difference in server settings, because the code works on my own webserver. I've checked with phpinfo() the following:</p>
  
  <pre><code>- Registered Stream Socket Transports   tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
  - OpenSSL support   enabled 
  - OpenSSL Library Version   OpenSSL 1.0.1e-fips 11 Feb 2013 
  </code></pre>
  
  <p>This is my PHP code:</p>
  
  <pre><code>    $emailname = MY_GMAIL_ACCOUNT_USERNAME;
      $emailpass = MY_GMAIL_ACCOUNT_PASSWORD;
  
      $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
        -&gt;setUsername($emailname)
        -&gt;setPassword($emailpass);
  
      $mailer = Swift_Mailer::newInstance($transport);
  
      $message = Swift_Message::newInstance($emailtitle)
        -&gt;setFrom(array($emailname.'@gmail.com' =&gt; $emailsender))
        -&gt;setTo(array($emailrecp))
        -&gt;setBody($emailbody,'text/html');
  
      $result = $mailer-&gt;send($message);
  </code></pre>