views:

149

answers:

1

This may be a ridiculous question, but it's been bothering me for a while. I have a mail forwarder piped to a PHP script, it receives perfectly, however I have the following error mailed back to me instantly:

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

As you can see, Exim thinks the header response an error from the script I have. The script can receive the Email perfectly from php://stdin but Exim is quick-replying with the error.

Plus,

  • It's running from console, not Apache so HTAccess or configuring Apache most likely would do nothing.
  • I can not find any solution, or anyone with the same problem.

So my question is: How to I get rid of those two headers?

Thanks, ~Jonny

Edit, Source:

    #!/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);
+2  A: 

looks like you're running php-cgi while you need php-cli (just "php"). Run php -v to make sure. If cgi is the case, try "-q" option.

stereofrog
As far as I tried with php -v it spammed back "Content-type: text/html", I went ahead and tried running it with the -q option and it still returned the headers.Exim is still being rather touchy with it.
JonnyLitt
try adding header('Content-type: '); to the top of your script. Also checkout http://www.php.net/manual/en/function.header-remove.php
Jimmy Ruska
eep, Did that, the problem is: I don't have PHP <= 5.3.0 (Needed for Header_remove), rather version 5.2.4. I can't update either because I am on a shared host and they've argued against it being paranoid about bugs in the newer PHP versions.
JonnyLitt
Didn't get it - what exactly does "php -v" say?
stereofrog
PHP 5.2.13 (cli) (built: Mar 3 2010 11:22:08) Copyright (c) 1997-2010 The PHP GroupZend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies with the ionCube PHP Loader v3.3.10, Copyright (c) 2002-2009, by ionCube Ltd., and with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
JonnyLitt
Aha! I hashbang'd the wrong PHP. I changed it to #!/usr/bin/php5 rather than #!/usr/bin/php and the errors have stopped.
JonnyLitt
Glad to hear it's working ;)
stereofrog
Haha, simple change by adding the 5, who knew xD. Thanks mate.
JonnyLitt