【问题标题】:Cakephp unable to send emailCakephp 无法发送电子邮件
【发布时间】:2012-06-14 16:17:01
【问题描述】:

我想使用 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.
                    }
 }

【问题讨论】:

    标签: php email cakephp


    【解决方案1】:

    这是开发人员一开始很常见的错误,更改你的App::uses并将它们分开:

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

    因为 cake 引用类的新方式。

    【讨论】:

      【解决方案2】:

      可能你必须修改 App::uses 因为 App::uses() 只允许两个参数,类名和它的位置,而你传递的是 4 个参数

      试试这个

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

      这里是参考uses

      Core Utility Library

      Email Basic Usage

      【讨论】:

        猜你喜欢
        • 2013-04-08
        • 2013-04-01
        • 2014-05-06
        • 2015-08-19
        • 2018-07-16
        • 1970-01-01
        • 2014-01-17
        • 2013-07-14
        • 2011-11-12
        相关资源
        最近更新 更多