PHP的mail()函数仅在代码中的特定点之后才引起500 Internal Server Error [英] PHP's mail() function causes a 500 Internal Server Error only after a certain point in the code

查看:116
本文介绍了PHP的mail()函数仅在代码中的特定点之后才引起500 Internal Server Error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前,自定义PHP应用程序中的所有mail()调用均导致500 Internal Server Error,并且记录的唯一错误是Premature end of script headers.通过SSH 有时运行文件会返回segfault. 奇怪的是,在mail()调用工作到停止工作之间(在Git中跟踪更改),没有代码更改.

Several days ago, all mail() calls in my custom PHP application cause a 500 Internal Server Error and the only error logged is Premature end of script headers. Running the file via SSH sometimes returns a segfault. The strange thing is no code changed between the time when the mail() call worked, and stopped working (changes are tracked in Git).

即使没有对代码进行任何更改,我还是经过检查并进行了常规检查(.htaccess,php.ini,自定义错误处理程序等),只是为了安全起见.

Even though no changes were made to the code, I still went through and did the normal checks (.htaccess, php.ini, custom error handler, etc), just to be safe.

我试图通过在应用程序中删除代码直到问题被查明来诊断问题.但是,这并没有将其范围缩小到特定的代码段,而是在mail()调用时加载到PHP(但尚未运行)的代码量.

I attempted to diagnose the problem by cutting out code in the application until the issue was pinpointed. However, this did not narrow it down to a specific piece of code, but rather the amount of code loaded into PHP (but not yet run) as the time of the mail() call.

在修剪后的应用程序中,我能够获得一个mail()调用来工作,但第二个调用却失败了.第一次调用紧接在include调用之前(require具有相同的结果).第二个是包含文件的开头(仅在开头的PHP标记之前).

In the trimmed application, I was able to get one mail() call to work, but the second would fail. The first call was immediately before an include call (require has same outcome). The second was at the very beginning of the included file (preceded only be the opening PHP tags).

我最初的想法是某种内存问题.奇怪的是,导致mail()调用引发错误所需的内存使用情况会根据从整个应用程序中保留/删除的代码而发生变化.如果仍然可以解决问题,则在包含文件之前,当前代码集合的内存使用情况为:

My original thoughts were it was some sort of memory issue. Oddly, the memory usage required to cause the mail() call to throw an error changes based on which code is kept/removed from the overall application. In case it can still help, the memory usage for the current collection of code before including the file is:

用途:3113696
最多:3352560

Usage: 3113696
Max: 3352560

包含文件后的内存使用情况仍然未知.

The memory usage after including the file is still unknown.

我已经与房东讨论了此问题,他们声称没有任何变化会导致此问题.

I've spoken to my host about the issue, and they claim nothing has changed that would cause this issue.

我无法在其他应用程序中重现此问题.

I have not been able to reproduce this issue in other applications.

  • PHP 5.3.10(5.2.17也受到影响)
  • MySQLi(特别是扩展MySQLi的自定义类)
  • Suhosin补丁0.9.10
  • 脚本头过早结束:XXX,引荐来源:XXX

在代码中的某个点之后(而不是在任何特定的调用之后)调用mail()而没有更改任何 PHP代码的情况下,导致我的PHP应用程序开始导致500 Internal Server Errors的原因是什么?

What would cause my PHP application to start causing 500 Internal Server Errors when mail() is called after a certain point in the code (but not after any specific call) without any PHP code being changed?

  • 不是超时问题-加载时间不到一秒
  • 不是内存限制问题-崩溃时仅使用〜3MB,但我有99MB的限制

推荐答案

转移到具有类似配置的其他服务器解决了该问题,因此,实际上这是主机服务器的问题(具体原因未知) ,遗憾的是,这可能仍然是个谜).

Transferring to a different server with similar configuration solved the problem, so it appears that it was, in fact, and issue with the host's server (specific cause is unknown, and regrettably, it will probably remain a mystery).

这篇关于PHP的mail()函数仅在代码中的特定点之后才引起500 Internal Server Error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆