脚本在 1m 后损坏,状态失败,PHP-Apache 使用 AWS SES 发送电子邮件时

Script is broken after 1m, status failed, PHP-Apache when sending email with AWS SES

环境(共享主机):

Versión Apache 2.4.41

Versión PHP 7.0.1

Versión MySQL 10.0.38-MariaDB-cll-lve

PHPMailer 6.1.4

我正在通过 PHPMailer 使用 AWS SNS SMTP 服务发送电子邮件消息,-所有配置都很好-,我进行了测试并且效果很好(1 或 2 条消息),因此,在生产中,我每 5 分钟发送 100 封电子邮件(不是垃圾邮件),但在 1m 纸条坏了。 我在日志和屏幕中没有收到任何错误消息,我只能在控制台中看到脚本在 1m 主体为空后损坏。 (下图)

注释

  1. 如果我每次只发送 50 封电子邮件,则脚本没有损坏。

  2. 如果我运行下面的脚本:

for($i = 1; $i < 131; $i++){
  echo $i.'<br>';
  sleep(1);
}

我得到:

Error 500 Request Timeout This request takes too long to process, it is timed out by the server. If it should not be timed out, please contact administrator of this web site to increase 'Connection Timeout'.

2m 后

  1. 我在脚本中有如下配置
error_reporting(E_ALL);
ini_set("display_errors", 1);
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 12000);
ignore_user_abort(TRUE);
ini_set("default_socket_timeout", 6000);
  1. 我在.htaccess
  2. 中有以下代码
php_value default_socket_timeout 6000
TimeOut 6000

我尝试了提到的更改 here 但不起作用。

最终,在搜索了很多选项之后,我找到了解决方案。此解决方案是关于 Litespeed 的特殊配置。

在所有请求的根目录.htaccess中添加

RewriteRule .* - [E=noabort:1]
RewriteRule .* - [E=noconntimeout:1]

Run PHP without Timeouts - Litespeed Doc