php - Gmail fsockopen() : SSL operation failed error with Codeigniter and XAMPP

标签 php codeigniter ssl xampp gmail

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

Filename: libraries/Email.php

Line Number: 1962

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:\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem 我试过禁用防火墙 我试过另一个网络

Codeigniter PHP 代码:

$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("\r\n");

    $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 项目发送电子邮件。它显示错误:

fsockopen() failed to enable crypto

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

替代方案

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

  • 打开 Avast

  • 点击设置(页面右上角)

  • 点击疑难解答

  • 点击重定向设置

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

  • 点击确定

  • 关闭 Avast

关于php - Gmail fsockopen() : SSL operation failed error with Codeigniter and XAMPP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34570064/

相关文章:

Java + SSL 使用自定义套接字

php - PHP 中的数据库类;只有一个功能 - 关于实践的问题以及它是否是一个好主意

php - Yii2。一个模型/数据库字段的多个输入

javascript - 如何在window.location javascript中传递php变量

php - 在循环内将数组添加到多维数组

java - 尝试解决 SSLHandshakeException 时获取 SocketTimeoutException

ssl - ECDSA 证书可以有 RSA 签名吗?

php android spinner - JSONObject 无法转换为 JSONArray

php - 在 Codeigniter ActiveRecord 查询中使用 IFNULL 和 CONCAT

codeigniter - CodeIgniter 的 CSRF token 问题