2

无效的电子邮件: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');

    }
}

得到上述错误。提前致谢

4

2 回答 2

1

域中的下划线无效,Application.from_email请将配置中的下划线更改为其他内容。

于 2013-09-04T06:05:09.057 回答
1

更改 from(Configure::read('Application.from_email')) 的配置

主要位于 app/Config/core.php 或任何其他配置文件中

配置将类似于:

$config['Application'] = array(
'from_email'=>'from@your_app_domain.com',
    .......... ................
);
于 2013-09-04T09:08:27.250 回答