title: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection timed out #110]'
body: <p>I had already searched it in google and tried all the suggestions here in <a href="http://stackoverflow.com">StackOverflow</a> but I still get a <b>Fatal Error:</b></p>
  
  <p>I am using <code>SwiftMailer</code> for sending and <b>email</b> to <b>GMAIL</b>. It works perfectly on my localhost but when I uploaded it and try It gives me a <b>Fatal Error:</b></p>
  
  <p>Here is a part of my code: </p>
  
  <pre><code>require_once 'Swift-5.1.0/lib/swift_required.php';
  
  
  $email = "fromemail@gmail.com";
  $transport = Swift_SmtpTransport::newInstance('ssl://smtp.gmail.com', 465);
  $transport-&gt;setUsername("username@gmail.com");
  $transport-&gt;setPassword("usernamepassword");
  
  // Create the message
  $message = Swift_Message::newInstance();
  $message-&gt;setTo(array(
     "to@gmail.com" =&gt; "First Name"
  ));
  $message-&gt;setCc(array("cc_email1@gmail.com" =&gt; "Name NAme" , "cc_email2@gmail.com" =&gt; "His Name"));
  
  $message-&gt;setSubject("Subject");
  
  $message-&gt;setBody("The Body");
  
  $message-&gt;setFrom($email, "Full Name");
  
  $message-&gt;setReplyTo(array($email =&gt; "Full Name"));
  
  // Send the email
  $mailer = Swift_Mailer::newInstance($transport);
  $mailer-&gt;send($message);
  </code></pre>
  
  <p><b>This is the Fatal Error I get when I send an email to gmail : </b></p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection timed out #110]' in /homepages/41/d513702051/htdocs/php/Swift-5.1.0/lib/classes/Swift/Transport/StreamBuffer.php:266 Stack trace: #0 /homepages/41/d513702051/htdocs/php/Swift-5.1.0/lib/classes/Swift/Transport/StreamBuffer.php(64): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 /homepages/41/d513702051/htdocs/php/Swift-5.1.0/lib/classes/Swift/Transport/AbstractSmtpTransport.php(115): Swift_Transport_StreamBuffer->initialize(Array) #2 /homepages/41/d513702051/htdocs/php/Swift-5.1.0/lib/classes/Swift/Mailer.php(80): Swift_Transport_AbstractSmtpTransport->start() #3 /homepages/41/d513702051/htdocs/php/contactus.php(33): Swift_Mailer->send(Object(Swift_Message)) #4 {main} thrown in /homepages/41/d513702051/htdocs/php/Swift-5.1.0/lib/classes/Swift/Transport/StreamBuffer.php on line 266</p>
  </blockquote>