我想使用cakePHP邮件程序系统,但我无法发送电子邮件,我收到以下错误:
Fatal error: Class 'CakeEmail' not found in D:... on line 100
我的控制器中定义了以下内容:
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.
}
}
答案 0 :(得分:4)
可能你必须修改 App :: uses ,因为App :: uses()只允许两个参数,类名及其位置,而你传递的是4个参数
试试这个
App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');
以下是参考uses
答案 1 :(得分:1)
这是开发人员最初常见的错误,更改您的App::uses
并将其分开:
App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');
由于蛋糕引用类的新方式。