在cakephp

时间:2015-06-16 18:59:39

标签: mysql cakephp-2.0 sendmail

您好我正在尝试发送邮件cakephp但收到错误消息

  

stream_socket_client():SSL操作失败,代码为1. OpenSSL   错误消息:错误:140770FC:SSL   例程:SSL23_GET_SERVER_HELLO:未知协议   stream_socket_client():无法启用加密   stream_socket_client():无法连接到ssl://smtp.gmail.com:25   (未知错误)

这是我的controller代码: -

public function contact(){
    //$this->loadModel('Contact');
    if($this->request->is(array('put','post'))){
        $this->set('data', $this->request->data);
        $this->Email->from = $this->data['Page']['email'];
        $this->Email->to = 'staff@mailinator.com';
        $this->Email->subject = 'Contact';
        $this->Email->template = 'contact';
        $this->Email->sendAs = 'html';
        $this->Email->smtpOptions = array(
        'post'=>465,
        'host'=>'ssl://smtp.gmail.com',
        'username'=>'staff@gmail.com',
        'password'=>'123456',
        'client'=>'gmail.com');
        $this->Email->delivery = 'smtp';
        //$this->Email->send();
        if($this->Email->send()) {
            $this->redirect(array('controller'=>'pages','action'=>'index'));
        }
        else{
            CakeLog::write('debug', $this->Email->smtpError);
        }
    }

}

1 个答案:

答案 0 :(得分:1)

应该有'port'=> 465而不是'post'=> 465。请更正