【问题标题】:fsockopen error after upgrading to php 7升级到 php 7 后出现 fsockopen 错误
【发布时间】:2016-06-04 09:22:38
【问题描述】:

我在数字海洋 nginx 和 php 7 上运行 codeigniter3.03。当我尝试发送电子邮件时,我收到此错误:

代码:

严重性:警告 消息:fsockopen():无法连接到 ssl://smtp.googlemail.com:465(连接超时) 文件名:库/Email.php 行号:1986

我的电子邮件设置是

$config['useragent'] = 'CodeIgniter';
$config['protocol'] = 'smtp';
//$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = 'xxxxxx@gmail.com';
$config['smtp_pass'] = 'xxxxxxxxxxxx';
$config['smtp_port'] = 465; 
$config['smtp_timeout'] = 5;
$config['wordwrap'] = TRUE;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['bcc_batch_mode'] = FALSE;
$config['bcc_batch_size'] = 200;

此版本在 php 5.x 下的相同配置中完美运行。

在 php.ini 我有

 extension=php_openssl.dll

已启用。

我无法在任何地方得到任何提示,为什么这在 php7 中不起作用。任何人都可以给我提示要检查什么或此错误的原因可能是什么。

【问题讨论】:

  • “超时”。阻止建立网络连接的东西。也许是防火墙或其他网络级别的东西。
  • 您使用的是什么版本的 PHP 5?
  • 另外,看起来您使用的是 Windows。你读过这里的注释吗——php.net/manual/en/openssl.installation.php
  • 似乎不是 SSL 或 PHP 版本问题。您是否尝试过像<?php fsockopen('smtp.googlemail.com', 465); 这样的套接字调用,看看是否超时。

标签: php nginx codeigniter-3


【解决方案1】:

你试过smtp.googlemail.com了吗?

还要注意这个其他答案,带有一个工作示例(似乎有所不同,例如在超时定义中):

另一种解决方案:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-09
    • 1970-01-01
    • 2017-06-14
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-24
    相关资源
    最近更新 更多