2012-03-25 6 views
0

私はCakePHP 2.0.6を使用しています。サーバのCakeEmail非オブジェクトエラー

私はCakeEmailを使用して簡単なEメールを送信しようとしています。私のコントローラで

私が持っている:私のコントローラのアクションで

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

$email = new CakeEmail('default'); 
       $email->to('[email protected]') 
        ->template('template') 
        ->viewVars(array('var' => $this->Object->findById($this->Object->id))) 
        ->emailFormat('html') 
        ->subject('Subject') 
        ->send(); 

私のデフォルトの電子メールの設定は次のとおりです。

public $clkei = array(
     'host' => 'ssl://smtpout.secureserver.net', 
     'port' => 465, 
     'username' => '[email protected]', 
     'password' => 'password', 
     'from' => array('[email protected]' => 'My Name'), 
     'transport' => 'Smtp' 
    ); 

私は得続けるしかし:

Fatal error: Call to a member function template() on a non-object in .../app/Controller/MyController.php on line 82 

私には何が欠けていますか?

ありがとうございました!

答えて

0

'viewVars'と 'template'なしで試してみましたか?試しに試してみる

$email = new CakeEmail('default'); 
      $email->to('[email protected]') 
       ->template('template') 
       ->viewVars(array('var' => $this->Object->findById($this->Object->id))) 
       ->emailFormat('html') 
       ->subject('Subject') 
       ->send();