title: Email configuration in CakePHP
body: <p>I'm trying to send mails through CakePHP, but I always got a 'Connection timed out' message. I've used two different configurations: gmail and 1and1, but result is the same.</p>
  
  <p>This is my <code>email.php</code> file:</p>
  
  <pre><code> public $oneandone = array(
      'host' =&gt; 'ssl://smtp.1and1.es',
      'port' =&gt; 465,
      'username' =&gt; 'my-address@my-domain.com',
      'password' =&gt; '*****',
      'transport' =&gt; 'Smtp',
      'timeout' =&gt; 1);
  
  public $gmail = array(
      'host' =&gt; 'smtp.gmail.com',
      'port' =&gt; 587,
      'username' =&gt; 'my-address@gmail.com',
      'password' =&gt; '****',
      'timeout' =&gt; 1,
      'tls' =&gt; true,
      'transport' =&gt; 'Smtp');
  </code></pre>
  
  <p>And this is my remind function inside the <code>UsersController.php</code> file:</p>
  
  <pre><code> public function remind() {
  
      App::uses('CakeEmail', 'Network/Email');
  
      $this-&gt;set('url', $this-&gt;referer());
  
      if ($this-&gt;request-&gt;is('post')) {
  
          $Email = new CakeEmail('gmail');
          $Email-&gt;from(array('my-address@my-domain.com' =&gt; 'Staff'));
          $Email-&gt;to('destiny@hotmail.com');
          $Email-&gt;subject('Password reminder');
          $Email-&gt;send('Here is your current password: xxxxxx');
  
          return $this-&gt;redirect(array('action' =&gt; 'login'));
      }
  }
  </code></pre>
  
  <p>The error I got is</p>
  
  <pre><code> if (!$this-&gt;_socket-&gt;connect()) {
  
          throw new SocketException(__d('cake_dev', 'Unable to connect to SMTP server.'));
  </code></pre>
  
  <p>so I don't know why I'm not being able to connect. I've modified some params like <code>tls</code>, <code>ssl</code> but no results.</p>
  
  <p>Within the same server (1and1) I can send emails with the standard <code>mail()</code> function, so I don't think it is a problem of PHP configuration. Correct me if I'm wrong.</p>
  
  <p>Some ideas would be appreciated!</p>