title: Swift_TransportException·Connection could not be established with host smtp.sendgrid.net [Connection timed out #110]
body: <p>I am using Laravel 4.2, which uses the swiftmailer lib for email.  I am trying to use the Sendgrid SMTP service but I am getting an timeout error on my staging server.  </p>
  
  <p><strong>Everything works fine in my local development.</strong></p>
  
  <p>mail.php</p>
  
  <pre><code>return array(
      'driver' =&gt; 'smtp',
      'host' =&gt; 'smtp.sendgrid.net',
      'port' =&gt; 587,
      'encryption' =&gt; 'tls',
      'username' =&gt; 'username'
      'password' =&gt; ...
  </code></pre>
  
  <p>I have switching to port 465 and 'ssl', works on the local but no luck on the server.  OpenSSL is enabled on the server.  </p>
  
  <p>What is interesting is Mandrill smtp (this uses a different laravel driver) and the local server smtp work fine on the server.</p>
  
  <p>The ports are open.  I can telnet into sendgrid from the server.  I also switched out the host name for the IPv4 just to checks because of all of the trouble people have with using smtp.gmail.com IPv4 vs IPv6.  Didn't make a difference.</p>
  
  <p>The specific error location is this:</p>
  
  <pre><code>    $this-&gt;_stream = @stream_socket_client($host.':'.$this-&gt;_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
      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>So my question is what should I check to figure out why swiftmailer and the stream_socket_client php function is working locally but not on the server.  Locally I am on a mac, the server is running centOS.</p>