title: CakePHP - can't email via SMTP
body: <p>pulling my hair out with this one.</p>
  
  <p>When I developed this cakephp (2.2) app on my local machine, I could email via gmail using smtp without a problem. Since then I've deployed it onto a 1and1 server and I can no longer send. What even more frustrating is that I cant seem to get any decent debugging info from cake.</p>
  
  <p>Heres the code:</p>
  
  <pre><code>if($fu['name']) {              
  
              $url = Router::url('/admin/', true );
              $ms = $url;
              $ms = wordwrap($ms,1000);
  
             //============Email================//
             // SMTP Options
             $this-&gt;Email-&gt;smtpOptions = array(
                 'port'=&gt;'465',
                 'timeout'=&gt;'30',
                 'host' =&gt; 'ssl://smtp.gmail.com',
                 'username'=&gt;'myemail@gmail.com',
                 'password'=&gt;'password'
                   );
             $this-&gt;Email-&gt;template = 'newExpenseClaim';
             $this-&gt;Email-&gt;from    = 'Expense Tracker &lt;myemail@email.co.uk&gt;';
             $this-&gt;Email-&gt;to      = 'myemail@fakeemail.com'; 
             $this-&gt;Email-&gt;subject = 'New Expense Claim Submitted - Please Review';
             $this-&gt;Email-&gt;sendAs = 'both';
  
             $this-&gt;Email-&gt;delivery = 'smtp';
  
             // Set username &amp; url in email
             $this-&gt;set('user', $fu['name']);
             $this-&gt;set('ms', $ms);
             //$this-&gt;Email-&gt;send();
  
             if(!$this-&gt;Email-&gt;send()) {
                  CakeLog::write('debug', $this-&gt;Email-&gt;smtpError);
              }
  
             $this-&gt;set('smtp_errors', $this-&gt;Email-&gt;smtpError);
  
             //============EndEmail=============//   
          }
  </code></pre>
  
  <p>I get the following debug info each times it fails (printed on screen, nothing goes into the debug log which is massively anoying).</p>
  
  <pre><code>    Connection refused
  
  Error: An Internal Error Has Occurred.
  Stack Trace
  
      CORE/Cake/Network/Email/SmtpTransport.php line 95 → CakeSocket-&gt;connect()
      CORE/Cake/Network/Email/SmtpTransport.php line 60 → SmtpTransport-&gt;_connect()
      CORE/Cake/Network/Email/CakeEmail.php line 1059 → SmtpTransport-&gt;send(CakeEmail)
      CORE/Cake/Controller/Component/EmailComponent.php line 345 → CakeEmail-&gt;send(null)
      APP/Controller/ExpenseClaimsController.php line 236 → EmailComponent-&gt;send()
      APP/Controller/ExpenseClaimsController.php line 278 → ExpenseClaimsController-&gt;notifyAdminsOfNewClaims()
      [internal function] → ExpenseClaimsController-&gt;add()
      CORE/Cake/Controller/Controller.php line 485 → ReflectionMethod-&gt;invokeArgs(ExpenseClaimsController, array)
      CORE/Cake/Routing/Dispatcher.php line 186 → Controller-&gt;invokeAction(CakeRequest)
      CORE/Cake/Routing/Dispatcher.php line 161 → Dispatcher-&gt;_invoke(ExpenseClaimsController, CakeRequest, CakeResponse)
      APP/webroot/index.php line 92 → Dispatcher-&gt;dispatch(CakeRequest, CakeResponse)
  </code></pre>
  
  <p>Can anyone help? Thanks in advance</p>
  
  <p>** Updated with wrapper and soctet info **</p>
  
  <p>These are the wrappers and sockets I get returned from those functions:</p>
  
  <p>Wrappers:</p>
  
  <pre><code>array(
      (int) 0 =&gt; 'https',
      (int) 1 =&gt; 'ftps',
      (int) 2 =&gt; 'compress.zlib',
      (int) 3 =&gt; 'compress.bzip2',
      (int) 4 =&gt; 'php',
      (int) 5 =&gt; 'file',
      (int) 6 =&gt; 'data',
      (int) 7 =&gt; 'http',
      (int) 8 =&gt; 'ftp',
      (int) 9 =&gt; 'zip'
  )
  </code></pre>
  
  <p>Sockets</p>
  
  <pre><code>array(
      (int) 0 =&gt; 'tcp',
      (int) 1 =&gt; 'udp',
      (int) 2 =&gt; 'unix',
      (int) 3 =&gt; 'udg',
      (int) 4 =&gt; 'ssl',
      (int) 5 =&gt; 'sslv3',
      (int) 6 =&gt; 'sslv2',
      (int) 7 =&gt; 'tls'
  )
  </code></pre>