Cakephp no puede enviar correo electrónico

I want to use the cakePHP mailer system, but I am unable to send an email, I get the following error:

 Fatal error: Class 'CakeEmail' not found in D:... on line 100

I have the following defined in my controller:

 App::uses('AppController', 'Controller','CakeEmail', 'Network/Email');

 // In the controller:
 public function search() {
      $email = new CakeEmail();
                    $email->from(array('noreply@assetchase.co.za' => 'Assetchase.co.za'));
                    $email->subject('result notification.');
                    foreach($emails as $value) {
                        $user = $this->User->find("first",array("fields" => array("username"),"conditions" => array("id" => $value)));
                        $email->to($user['User']['username']);
                        $email->send('A new notification, booyah!');
                        // Send an email with the username.
                    }
 }

preguntado el 11 de junio de 12 a las 19:06

2 Respuestas

Probably you have to modify App::uses because App::uses() only allows two arguments the class name and its location and you are passing 4 parameter instead

Prueba esta

App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');

Aquí está la referencia usos

Core Utility Library

Email Basic Usage

Respondido el 11 de junio de 12 a las 19:06

This is a very common error that developers do at first, Change your App::uses and separate them:

App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');

Because of the new way cake references the classes.

Respondido el 04 de Septiembre de 13 a las 15:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.