PHPMailer报错stream_select(): unable to select是什么原因?

如题,PHPMailer在5.6版本会报这个错误,但是在7以上版本就没问题,没接触过socket,不知道是什么原因。

错误有两种,一个是No such file or directory,另一个是Resource temporarily unavailable。
都是1228行的stream_select引起的

2022-11-13 04:47:09 Connection: opening to smtp.163.com:25, timeout=300, options=array()
2022-11-13 04:47:09 Connection: opened
2022-11-13 04:47:09 Connection failed. Error #2: stream_select(): unable to select [2]: No such file or directory (max_fd=884) [\vendor\phpmailer\phpmailer\src\SMTP.php line 1228]
2022-11-13 04:47:09 SMTP -> get_lines(): select failed (stream_select(): unable to select [2]: No such file or directory (max_fd=884))
2022-11-13 04:47:09 SERVER -> CLIENT:
2022-11-13 04:47:09 Connection: closing due to error
2022-11-13 04:47:09 Connection: closed
SMTP Error: Could not connect to SMTP host.

1228行节选

......
stream_set_timeout($this->smtp_conn, $this->Timeout);
if ($this->Timelimit > 0) {
    $endtime = time() + $this->Timelimit;
}
$selR = [$this->smtp_conn];
$selW = null;
while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
//Must pass vars in here as params are by reference
//solution for signals inspired by https://github.com/symfony/symfony/pull/6540
set_error_handler([$this, 'errorHandler']);
// $n为报错的1228行
$n = stream_select($selR, $selW, $selW, $this->Timelimit);
restore_error_handler();
......
阅读 1.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题