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,
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);
In PHP, a coder can terminate the execution of a script by specifying a method/function called the exit() method in a script. Even if the exit() function is called, the shutdown functions and object destructors will be executed without interruption.
The header() function in PHP sends a raw HTTP header to a client or browser. Before HTML, XML, JSON, or other output is given to a browser or client, the server sends raw data as header information with the request (particularly HTTP Request).
header() will not stop the script and things below will continue to be parsed. If you scroll down to the comments on the php function page for exit(), some people have added hints and tips to make this action a little cleaner... if you feel up for a challenge!
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.
Had the same issue. My hosts told me I could use php-5.4-cli (normally I used php-5.4).
Adding -cli worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With