【发布时间】:2018-05-24 16:24:45
【问题描述】:
我无法使用 CodeIgniter 发送邮件。它显示以下错误。
fwrite(): send of 28 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host.
这是我在 email.php 库中的设置
public $useragent = 'CodeIgniter';
public $mailpath = '/usr/sbin/sendmail'; // Sendmail path
public $protocol = 'smtp'; // mail/sendmail/smtp
public $smtp_host = 'smtp.mailhostbox.com';
public $smtp_user = 'xxx@xx.in';
public $smtp_pass = 'xxxxxx';
public $smtp_port = 25;
public $smtp_timeout = 5;
public $smtp_keepalive = FALSE;
public $smtp_crypto = '';
public $newline = "\r\n";
我可以发送电子邮件到昨天。但是从今天早上开始,它会显示此错误。
更新:
我已将主机更改为 gmail ,但仍然无法正常工作。以下是我所做的更改
public $useragent = 'CodeIgniter';
public $mailpath = '/usr/sbin/sendmail'; // Sendmail path
public $protocol = 'smtp'; // mail/sendmail/smtp
public $smtp_host = 'smtp.gmail.com';
public $smtp_user = 'noreply.xxx@gmail.com';
public $smtp_pass = 'xxxxxx';
public $smtp_port = 465;
public $smtp_timeout = 5;
public $smtp_keepalive = FALSE;
public $smtp_crypto = 'ssl';
public $newline = "\r\n";
但它显示错误为Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465:465 (Failed to parse address "smtp.gmail.com:465:465")
我将端口从465改为587如下
public $smtp_port = 587;
public $smtp_crypto = 'tls';
但我得到了这个错误
Message: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
我不明白真正的问题是什么,因为它在所有可能的情况下都会引发错误
【问题讨论】:
-
将
$smtp_port值更改为465 -
我将端口更改为
465,但我得到了一些其他错误fsockopen(): unable to connect to smtp.mailhostbox.com:465 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) -
我已经检查过,那里列出的建议对我不起作用
-
你初始化配置了吗?
标签: php codeigniter email