升级到php 7后出现fsockopen错误

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

码:

Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)
Filename: libraries/Email.php
Line Number: 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中工作.任何人都可以给我一个提示要检查的内容或这个错误的原因是什么.

你有没有试过smtp.googlemail.com?

另请注意另一个答案,一个工作示例(例如在超时定义中似乎有所不同):

> phpmailer send gmail smtp timeout

另一种方案:

> Having trouble with PHPMailer

转载注明原文:升级到php 7后出现fsockopen错误 - 代码日志