I am trying to pipe an email to PHP. I currently have set up a forwarder in cPanel that does the following :
|/home/username/public_html/mailscripttest.php
mailscripttest.php has permissions 755 and contains:

#!/usr/bin/php –q
<?
/* Read the message from STDIN */
$fd = fopen("php://stdin", "r"); 
$email = ""; // This will be the variable holding the data.
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
/* Saves the data into a file */
$fdw = fopen("mail.txt", "w+");
fwrite($fdw, $email);
fclose($fdw);
/* Script End */

However when I send an email I get a bounced message saying:

This message was created automatically by mail delivery software.

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/username/public_html/mailscripttest.php
generated by test-script@nicholasquinlan.com
local delivery failed

The following text was generated during the delivery attempt:

------ pipe to |/home/username/public_html/mailscripttest.php
generated by test-script@nicholasquinlan.com ------

Status: 404 Not Found
X-Powered-By: PHP/5.2.13
Content-type: text/html

No input file specified.

------ This is a copy of the message, including all the headers. ------

What am I doing wrong and how can I fix it?
Thanks.
--
Nick

Before trying to sort out the code, are you sure that your web host allows piping mail to php. I know that mine doesn't and that is probably fairly common.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.