0

嘿任何人都可以帮助我摆脱这个问题,我收到以下错误遇到 PHP 错误

Severity: Warning

Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:587 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)

Filename: libraries/Email.php

Line Number: 1689

A PHP Error was encountered

Severity: Warning

Message: fwrite() expects parameter 1 to be resource, boolean given

Filename: libraries/Email.php

Line Number: 1846

我的电子邮件类中有以下代码

Class MailSender extends CI_Model{

    function __construct(){
        parent::__construct();
    }

    public function sendMail(){
        $config=array(
                'protocol'=>'smtp',
                'smtp_host'=> 'ssl://smtp.googlemail.com',
                'smtp_port' => 587,
                'smtp_user' => 'bhatta.bj@gmail.com',
                'smtp_pass' => 'signature08'
        );

        $this->load->library('email',$config);
        $this->email->set_newline("\r\n");

        $this->email->from("bhatta.bj@gmail.com");
        $this->email->to("curtains_v@hotmail.com");
        $this->email->subject("this is a sample mail");
        $this->email->message("this is a sample message please check this");

        if($this->email->send()){
            //$data['message']="Email sent successfully";
            return true;

        }else{
            //$data['message']="Couldnt sent the email, please provide me valid email address";
            return false;
        }

    }
}
4

2 回答 2

1

代码工作正常,请确保您已加载 openssl 扩展。

http://www.devcha.com/2010/01/php-fsockopen-unable-to-connect-ssl.html

于 2012-06-06T01:04:02.173 回答
0

您是否实际加载了 openssl 扩展程序?使用 phpinfo();在 .php 文件中查看是否加载了 openssl 扩展或者您是否对导致此问题的 php.ini 进行了任何修改?

于 2012-06-06T01:03:20.333 回答