6

这可能是一个荒谬的问题,但它一直困扰着我一段时间。我有一个通过管道传输到 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 很可能什么都不做。
  • 我找不到任何解决方案,或者任何有同样问题的人。

所以我的问题是:如何摆脱这两个标题?

谢谢,~强尼

编辑,来源:

    #!/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);
4

2 回答 2

16

看起来您在需要 php-cli(只是“php”)时正在运行 php-cgi。运行 php -v 以确保。如果 cgi 是这种情况,请尝试“-q”选项。

于 2010-03-14T20:44:35.740 回答
1

有同样的问题。我的主机告诉我我可以使用 php-5.4-cli(通常我使用 php-5.4)。

添加 -cli 对我有用。

于 2015-09-15T10:02:20.740 回答