title: 'Connection could not be established with host smtp.gmail.com [Unable to find the socket transport "ssl"
body: <p>I'm trying to send a message with SwiftMailer using localhost. However I keep getting the error:</p>
  
  <pre><code>560:tid 1472] [client ::1:65504] PHP Fatal error:  Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? #166044768]'
  </code></pre>
  
  <p>I've had a look around stackoverflow and it's related questions, and i have changed to port to 465 and 587, and went into the php.ini file and removed the semicolon ( ; ) from</p>
  
  <pre><code>extension=php_openssl.dll
  </code></pre>
  
  <p>However, when I try to run my code, I still get the above mentioned error.</p>
  
  <p>My code:</p>
  
  <pre><code>require_once '../lib/swift_required.php';
  
  $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
      -&gt;setUsername('mymail@gmail.com')
      -&gt;setPassword('password');
  
  $mailer = Swift_Mailer::newInstance($transport);
  $message = Swift_Message::newInstance()
      -&gt;setSubject('Localhost email test')
      -&gt;setFrom(array('mymail@gmail.com' =&gt; 'test'))
      -&gt;setTo(array('testmail@hotmail.com' =&gt; 'receiver'))
      -&gt;setBody('This is a test message');
  
  if ($mailer-&gt;send($message)) {
      echo 'The message was sent successfully!';
  
  } else {
      echo 'Error sending email message';
  }
  </code></pre>
  
  <p>Would appreciate any help I can get. Thanks!</p>