title: Using gmail smtp via Laravel: Connection could not be established with host smtp.gmail.com [Connection timed out #110]
body: <p>When I try to use GMail SMTP for sending email via Laravel, I encounter the following error:</p>
  
  <pre><code>Swift_TransportException
  
  Connection could not be established with host smtp.gmail.com [Connection timed out #110]
  </code></pre>
  
  <p>It is the trace of the error:</p>
  
  <pre><code>...
   }
  $this-&gt;_stream = @stream_socket_client($host.':'.$this-&gt;_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));
  if (false === $this-&gt;_stream) {
  throw new Swift_TransportException(
  'Connection could not be established with host ' . $this-&gt;_params['host'] .
  ' [' . $errstr . ' #' . $errno . ']'...
  </code></pre>
  
  <p>and here are my configuration for mail:</p>
  
  <pre><code>'driver' =&gt; 'smtp',
  
  'host' =&gt; 'smtp.gmail.com',
  
  'port' =&gt; 587,
  
  'from' =&gt; array('address' =&gt; 'some@example.ir', 'name' =&gt; 'some'),
  
  'encryption' =&gt; 'tls',
  
  'username' =&gt; 'myemail@gmail.com',
  
  'password' =&gt; 'mypassword',
  
  'sendmail' =&gt; '/usr/sbin/sendmail -bs',
  
  'pretend' =&gt; false
  </code></pre>
  
  <p>I use a shared host and the port 587 on localhost is open.</p>