我試圖讓我正在開發的網站發送密碼提醒電子郵件。我有想用我的Gmail帳戶來測試。從蛋糕食譜,我有這樣的代碼:使用Gmail從CakePHP應用程序發送電子郵件
$this->Email->from = '[email protected]';
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.gmail.com',
'username'=>'[email protected]',
'password'=>'notmyrealpassword');
$this->Email->delivery = 'smtp';
$this->Email->from = '[email protected]';
$this->Email->to = $this->request->data['User']['email'];
$this->Email->subject = 'Your account reset request';
$this->Email->send('testing');
$this->Email->send();
debug($this->Email->smtpError);
然而,當這個代碼執行GES我歌廳此錯誤:
Error: Call to a member function messageID() on a non-object
File: C:\xampp\htdocs\site\lib\Cake\Controller\Component\EmailComponent.php
Line: 312
Notice: If you want to customize this error message, create app\View\Errors\fatal_error.ctp
我在做什麼錯在這裏?目前我只想測試我的應用程序是否可以正常發送電子郵件。但是,Gmail是否會將電子郵件發送給我的用戶?
謝謝。
爲什麼不直接使用本地sendmail? :) – 2012-08-17 01:11:03
更好地使用新的CakeEmail類,而不是組件。這個錯誤是由於在調用send()之前沒有設置主題,儘管你的代碼顯示你確實設置了它。這是致命的實際代碼?你也要調用send()兩次。 – Ceeram 2012-08-17 08:48:17