Reputation: 3592
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.
}
}
Upvotes: 0
Views: 1447
Reputation: 22081
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.
Upvotes: 1
Reputation: 8461
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
Try this
App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');
Here is the reference uses
Upvotes: 4