0
当我试图使用Cakephp发送电子邮件时,我得到“未知的电子邮件配置'gmail'”错误,是因为我从本地主机(xampp)发送它?发送电子邮件时出错CakePHP
if($this->User->save($this->request->data)){
$message='Click on the link below to complete registration ';
$confirmation_link='www.sitename.com/users/verify/t:'.$hash.'/n:'.$this->data['User']['username'].'';
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail('gmail');
$email->Email->from = '[email protected]';
$email->Email->to=$this->data['User']['email'];
$email->Email->subject = 'Confirm Registration';
$email->Email->smtpOptions = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => '[email protected]',
'password' => 'mypassword',
'transport' => 'Smtp'
);
$email->send($message . " " . $confirmation_link);
$this->Session->setFlash(__('you should activate your account'));
}
}
感谢这么多的人,没有更多的错误!但使用本地主机与cakephp发送电子邮件是可能的?我找不到有关该 – Exchanger13 2014-10-09 01:43:27
的任何参考它真的取决于您的本地主机的环境。如果我们正确配置环境,则可以使用本地主机发送电子邮件。把它当作真正的服务器。当你直接在真正的服务器上开发时,它也是一个'本地主机',对吗? – kyo 2014-10-09 03:56:56