title: CakePhp Could not send email
body: <p>When i try to send message in cakephp or register a new user i receive:</p>
  
  <pre><code>Could not send email.
  </code></pre>
  
  <p>Error: An Internal Error Has Occurred.
  Stack Trace</p>
  
  <pre><code>CORE\Cake\Network\Email\MailTransport.php line 47 → MailTransport-&gt;_mail(string, string, string, string, null)
  CORE\Cake\Network\Email\CakeEmail.php line 1066 → MailTransport-&gt;send(CakeEmail)
  CORE\Cake\Controller\Component\EmailComponent.php line 347 → CakeEmail-&gt;send(null)
  APP\Plugin\Messages\Controller\MessagesController.php line 158 → EmailComponent-&gt;send()
  [internal function] → MessagesController-&gt;add(string)
  CORE\Cake\Controller\Controller.php line 486 → ReflectionMethod-&gt;invokeArgs(MessagesController, array)
  CORE\Cake\Routing\Dispatcher.php line 187 → Controller-&gt;invokeAction(CakeRequest)
  CORE\Cake\Routing\Dispatcher.php line 162 → Dispatcher-&gt;_invoke(MessagesController, CakeRequest, CakeResponse)
  APP\webroot\index.php line 96 → Dispatcher-&gt;dispatch(CakeRequest, CakeResponse)
  </code></pre>
  
  <p>i'm new in CakePhp and i edit this file, in app/Config/email.php</p>
  
  <pre><code>    public $smtp = array(
      'transport' =&gt; 'Smtp',
      'from' =&gt; array('simone.zambenedetti@uniroma1.it' =&gt; 'My Site'),
      'host' =&gt; 'ssl://smtp.gmail.com',
      'port' =&gt; 465,
      'timeout' =&gt; 30,
      'username' =&gt; '**user**', //hidden
      'password' =&gt; '**my secret**', //hidden
      'client' =&gt; null,
      'log' =&gt; false
      //'charset' =&gt; 'utf-8',
      //'headerCharset' =&gt; 'utf-8',
  );
  </code></pre>
  
  <p>also edit lib/Cake/Network/Email/CakeEmail.php</p>
  
  <pre><code>    protected $_transportName = 'Smtp';
  </code></pre>
  
  <p>and edit lib/Cake/Network/Email/SmtpTransport.php</p>
  
  <pre><code>public function config($config = array()) {
      $default = array(
          'host' =&gt; 'ssl://smtp.gmail.com',
          'port' =&gt; 465,
          'timeout' =&gt; 30,
          'username' =&gt; 'simone.zambenedetti@uniroma1.it',
          'password' =&gt; 'enomis58',
          'client' =&gt; null,
          'tls' =&gt; false
      );
      $this-&gt;_config = $config + $default;
  }
  </code></pre>
  
  <p>Please help me... everithing work, not email or message.
  If u want to recreate the error you could register on my site
  <a href="http://bbcd.bio.uniroma1.it/eventi/" rel="nofollow">http://bbcd.bio.uniroma1.it/eventi/</a></p>
  
  <p>Thx everyone answer me.</p>
  
  <hr>
  
  <p>Here the Code:</p>
  
  <pre><code>                foreach($usersTo as $userTo) {
                  if($userTo['User']['notification'] &amp;&amp; $userTo['User']['id']!=$this-&gt;Auth-&gt;user('id')) {
                      $this-&gt;set('message_id', $parent_id);
                      $this-&gt;set('message', $this-&gt;request-&gt;data['Message']['message']);
                      $this-&gt;Email-&gt;reset();
                      $this-&gt;Email-&gt;from = Configure::read('evento_settings.systemEmail');
                      $this-&gt;Email-&gt;to = $userTo['User']['username'].'  &lt;'.$userTo['User']['email'].'&gt;';
                      $this-&gt;Email-&gt;replyTo = Configure::read('evento_settings.systemEmail');
                      $this-&gt;Email-&gt;return = Configure::read('evento_settings.systemEmail');
                      $this-&gt;Email-&gt;subject = __('You have a new message in').' ';
                      $this-&gt;Email-&gt;subject.= Configure::read('evento_settings.appName');
                      $this-&gt;Email-&gt;delivery = 'mail';
                      $this-&gt;Email-&gt;template = 'Messages.new_message';
                      $this-&gt;Email-&gt;sendAs = 'both';
                      $this-&gt;Email-&gt;send();
                      //debug($this-&gt;Session-&gt;read('Message.email'));exit;
                  }
  </code></pre>