这可能是一个荒谬的问题,但它已经困扰了我一段时间。 我有一个通过管道传输到 PHP 脚本的邮件转发器,它可以完美接收,但是我立即收到以下错误邮件:
A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:
pipe to |/home/[webroot]/public_html/external/mobile/email.php
generated by mobile@[mydomain]
The following text was generated during the delivery attempt:
X-Powered-By: PHP/5.2.13
Content-type: text/html
如您所见,Exim 认为标题响应是我的脚本中的一个错误。该脚本可以完美地接收来自 php://stdin 的电子邮件,但 Exim 会快速回复错误。
另外,
- 它从控制台运行,而不是 Apache,因此 HTAccess 或配置 Apache 很可能什么都不做。
- 我找不到任何解决方案,也找不到任何有相同问题的人。
所以我的问题是:如何摆脱这两个 header ?
谢谢, ~强尼
编辑,来源:
#!/usr/bin/php
<?php
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
$dat = fopen(dirname(__FILE__).'/test.txt', 'w');
fwrite($dat, $email);
fclose($dat);
最佳答案
看起来您正在运行 php-cgi,而您需要 php-cli(只是“php”)。运行 php -v 以确保。如果是 cgi,请尝试“-q”选项。
关于php - 从命令行执行时如何阻止 PHP 返回 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2443575/