GMail fsockopen():使用 Codeigniter 和 XAMPP 的 SSL 操作失败错误

2022-01-14 00:00:00 ssl gmail xampp php codeigniter

错误消息 1:消息:fsockopen():SSL 操作失败,代码为 1.OpenSSL 错误消息:错误:14090086:SSL 例程:ssl3_get_server_certificate:certificate verify failed

Error message 1: Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

文件名:libraries/Email.php

Filename: libraries/Email.php

行号:1962

错误消息 2:消息:fsockopen():无法启用加密错误消息 3:消息:fsockopen(): 无法连接到 >ssl://smtp.gmail.com:465(未知错误)

Error message 2: Message: fsockopen(): Failed to enable crypto Error message 3: Message: fsockopen(): unable to connect to >ssl://smtp.gmail.com:465 (Unknown error)

php.ini: extension=php_openssl.dll ->未注释我试过: openssl.cafile= C:xamppperlvendorlibMozillaCAcacert.pem我试过禁用防火墙我已尝试使用另一个网络

php.ini: extension=php_openssl.dll -> uncommented I have tried with: openssl.cafile= C:xamppperlvendorlibMozillaCAcacert.pem I have tried with disabled firewall I have tried with another network

Codeigniter PHP 代码:

Codeigniter PHP Code:

$config = Array(
        'protocol'  => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' => 465,
        'smtp_user' => 'asd@gmail.com',
        'smtp_pass' => 'asd',
        'mailtype'  => 'html',
        'charset'   => 'utf-8'
    );

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

    $this->email->from('1@gmail.com', 'asd');
    $this->email->to($recipient);

    $this->email->subject($a);
    $this->email->message($b);

    $this->email->send();

推荐答案

在我的例子中,Avast Antivirus 阻止了端口.我使用 SMTP 端口 465 从我的 CodeIgniter 项目发送电子邮件.它显示了一个错误:

In my case, the Avast Antivirus was blocking the port. I was using the SMTP port 465 for sending an email from my CodeIgniter project. It showed an error:

fsockopen() 未能启用加密

只需禁用 Avast Antivirus 即可解决问题.

Simply disabling the Avast Antivirus solved the problem.

但如果您想保持 Avast 安全,您应该:

But if you want to keep your Avast security on, you should:

  • 打开 Avast

  • Open Avast

点击设置(页面右上角)

点击疑难解答

点击重定向设置

从重定向设置的MAIL部分清除您使用的端口

Clear the port you used from Redirect Settings's MAIL section

点击确定

关闭 Avast

相关文章