在我的用户控制器中,我添加了:
App::uses('CakeEmail', 'Network/Email');
class UsersController extends AppController {
function sign_up() {
$this->autoRender = false;
$email = new CakeEmail('default');
$email->template('sign_up');
$email->emailFormat('html');
$email->subject('Addience.com Sign Up');
$email->to($this->request->query['email']);
$email->viewVars(array('password' => $this->Password->generatePassword(), 'email' => $this->request->query['email'], 'key' => $this->Password->generateKey()));
$email->send();
$this->redirect('/');
}
}
我的 email.php 配置文件如下所示:
class EmailConfig {
public $default = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'xxx@gmail.com',
'password' => 'xxx',
'from' => array('support@xxx.com' => 'xxx'),
'transport' => 'Smtp'
);
}
但是,我仍然得到:
Notice (8): Undefined index: email [APP\Controller\UsersController.php, line 311]
Notice (8): Undefined index: email [APP\Controller\UsersController.php, line 312]
You need specify one destination on to, cc or bcc.
Error: An Internal Error Has Occurred.
Stack Trace
#0 C:\xampp\htdocs\addience\Controller\UsersController.php(314): CakeEmail->send()
#1 [internal function]: UsersController->sign_up()
#2 C:\xampp\htdocs\cakephp-2.0.6\lib\Cake\Controller\Controller.php(473): ReflectionMethod->invokeArgs(Object(UsersController), Array)
#3 C:\xampp\htdocs\cakephp-2.0.6\lib\Cake\Routing\Dispatcher.php(104): Controller->invokeAction(Object(CakeRequest))
#4 C:\xampp\htdocs\cakephp-2.0.6\lib\Cake\Routing\Dispatcher.php(86): Dispatcher->_invoke(Object(UsersController), Object(CakeRequest), Object(CakeResponse))
#5 C:\xampp\htdocs\addience\webroot\index.php(98): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#6 {main}
为什么?
谢谢!