php - 托管中的 CodeIgniter 电子邮件 : fsockopen(): Unable to connect to ssl://smtp. gmail.com

标签 php codeigniter email ssl

我使用 CodeIgniter 电子邮件库来制作忘记密码功能。当我在本地主机上尝试时,一切顺利,没有错误。但是当我移动到托管服务器时,会出现这样的错误:

Severity: Warning

Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection timed out)

Filename: libraries/Email.php

Line Number: 1986

这是我的代码:

$ci = get_instance();
        $ci->load->library('email');
        $config['protocol'] = "smtp";
        $config['smtp_host'] = "ssl://smtp.gmail.com";
        $config['smtp_port'] = "465";
        $config['smtp_user'] = "xxxxxxx@gmail.com";
        $config['smtp_pass'] = "xxxxxxx";
        $config['charset'] = "utf-8";
        $config['mailtype'] = "html";
        $config['newline'] = "\r\n";

        $ci->email->initialize($config);

我应该怎么做才能修复这个错误?

最佳答案

您需要启用 SSL。 加载 php.ini 并找到包含以下内容的行:

;extension=php_openssl.dll

通过删除分号取消注释:

extension=php_openssl.dll

这对我有用

关于php - 托管中的 CodeIgniter 电子邮件 : fsockopen(): Unable to connect to ssl://smtp. gmail.com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36562153/

相关文章:

php - Laravel: Blade View 中的 undefined variable

php - 尝试从 2 个表 codeigniter 获取数据时出错

jquery - CodeIgniter-jQuery;显示/隐藏错误类别

ruby-on-rails - 在 Rails 中验证多封电子邮件和处理错误的最佳方式是什么?

php - 将电子邮件回复保存在数据库中

email - S/MIME 中的多个签名

php - 检查用户名是否存在 PDO

php - 如何在 PHP redis 中使用正则表达式查找 redis 键?

php - IE 和空白

javascript - 我想在 codeigniter 中禁用 datetimepicker 中的过去时间