Php Codeigniter 2.1.3的SMTP Gmail错误

Php Codeigniter 2.1.3的SMTP Gmail错误,php,codeigniter,email,smtp,Php,Codeigniter,Email,Smtp,我看过很多与这个问题相关的帖子,我已经完成了给出的指令,但总是得到相同的错误 我想使用Code Igniter 2.1.3发送smtp gmail,代码如下: class Email extends CI_Controller{ function index(){ $config = Array( 'protocol' => 'smtp', 'smtp_crypto' => 'ssl', 'smtp_host' => 'smtp.gmail.com',

我看过很多与这个问题相关的帖子,我已经完成了给出的指令,但总是得到相同的错误

我想使用Code Igniter 2.1.3发送smtp gmail,代码如下:

class Email extends CI_Controller{

function index(){

$config = Array(
'protocol'      => 'smtp',
'smtp_crypto'   => 'ssl',
'smtp_host'     => 'smtp.gmail.com',
'smtp_user'     => 'myEmail@gmail.com',
'smtp_pass'     => '***********',
'smtp_port'     => 25,
'mailtype'      => 'text',
'smtp_timeout'  =>  15, 
'charset'       => 'iso-8859-1'
);
$this->load->library('email', $config);

$this->email->set_crlf("\r\n");
$this->email->set_newline("\r\n");
$this->email->from("myEmail@gmail.com", "myName");
$this->email->to("myEmail@gmail.com");
$this->email->subject("Email Test");
$this->email->message("This is email test");

if($this->email->send()){
    echo 'Email Send';
    }   else{
        show_error($this->email->print_debugger());
    }
}
错误总是这样的

Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:25 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )

请帮助我修复此错误,谢谢:)

您需要在服务器配置中启用php.ini文件中的ssl,如果您使用的是Xampp服务器,您可以检查它是否已启用。在该页面中,转到PHP信息搜索ssl

你需要删除;在extension=php_openssl.dll之前,请在php.ini文件中输入这一行

您需要启用OpenSSL

我最近遇到了这个错误。您的代码中有一个小错误

function sendMail()
{
    $config = Array(
  'protocol' => 'smtp',
  'smtp_host' => 'ssl://smtp.googlemail.com',
  'smtp_port' => 465,
  'smtp_user' => 'xxx@gmail.com', // change it to yours
  'smtp_pass' => 'xxx', // change it to yours
  'mailtype' => 'html',
  'charset' => 'iso-8859-1',
  'wordwrap' => TRUE
);

        $message = $this->load->view('upload_success','',TRUE);
        $this->load->library('email', $config);
      $this->email->set_newline("\r\n");
      $this->email->from('xxx@gmail.com'); // change it to yours
      $this->email->to('yyy@gmail.com');// change it to yours
      $this->email->subject('Resume from JobsBuddy for your Job posting');
      $this->email->message($message);
      if($this->email->send())
     {
      echo 'Email sent.';
     }
     else
    {
     show_error($this->email->print_debugger());
    }

}

这是我在解决您面临的问题后正在使用的工作代码。…

如果我的答案对您有用,请接受它作为答案。我尝试了您的代码,但出现了相同的错误,我在我的php.ini上启用了开放ssl扩展。您怎么能说u r enabled u r openssl in enabled。你有证据吗。检查本地主机。PHP信息选项卡搜索openssl。您将发现已启用。我已检查phpinfo,opensll支持已启用,我正在使用wamp服务器。k检查已启用的套接字流………我还在windows中使用xampp服务器。