In my controller i'm using a email function with the following code:
public function email($mail = null){
$email = new CakeEmail('default');
$email->config('default');
$email->from(array('[email protected]' => 'testing'));
$email->to('$mail');
$email->subject('Approved');
$email->send('Approved');
At the top i have
App::uses('AppController', 'Controller', 'CakeEmail', 'Network/Email');
However, i receive the error Fatal error: Class 'CakeEmail' not found in.
I'm not sure where i have gone wrong. Can anybody please assist?
You need to change your App::uses and separate the two:
App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');
App::uses()
does only allow two arguments: $className
and $location
. You passed 4 arguments, that's why CakeEmail is not loaded.
See http://api20.cakephp.org/class/app#method-Appuses and http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::uses for more information
the documentation is pretty clear about it: http://book.cakephp.org/2.0/en/core-utility-libraries/email.html?highlight=cakeemail#CakeEmail
"First of all, you should ensure the class is loaded"
on a second look: your app::uses() is wrong. check out the way it is documented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With