无效的电子邮件:cakephp中的“from@your_app_domain.com”
我在控制器中写了这段代码:
public function remember_password()
{
if ($this->request->is('post')) {
$user = $this->User->findByEmail($this->request->data['User']['email']);
if (empty($user)) {
$this->Session->setFlash('This email does not exist in our database.', 'flash_fail');
$this->redirect(array('action' => 'login'));
}
$hash = $this->User->generateHashChangePassword();
$data = array(
'User' => array(
'id' => $user['User']['id'],
'hash_change_password' => $hash
)
);
$this->User->save($data);
$email = new CakeEmail();
$email->template('remember_password', 'default')
->config('gmail')
->emailFormat('html')
->subject(__('Remember password - ' . Configure::read('Application.name')))
->to($user['User']['email'])
->from(Configure::read('Application.from_email'))
->viewVars(array('hash' => $hash))
->send();
$this->Session->setFlash('Check your e-mail to continue the process of recovering password.', 'flash_success');
}
}
得到上述错误。提前谢谢
答案 0 :(得分:1)
域中的下划线无效,请将配置中的Application.from_email
更改为其他内容。
答案 1 :(得分:1)
更改配置for(Configure :: read('Application.from_email'))
主要位于app / Config / core.php或任何其他配置文件
中配置将类似于:
$config['Application'] = array(
'from_email'=>'from@your_app_domain.com',
.......... ................
);