管道电子邮件到PHP脚本

I have a simple php script that I want called when an email is sent to a specific email address and dump it into a text file:

#!/usr/bin/php -q
<?
$fd = fopen("php://stdin", "r"); 
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
$fdw = fopen("email.txt", "w+");
fwrite($fdw, $email);
fclose($fdw);
?>
  • both result.php and email.txt are located above public_html
  • email address was set up
  • forwarder was created to point to the correct path for result.php
  • permission for both files are set to 744

When I send an email to the email address for the pipe script...I get the email, but nothing happens with the script. I do not get any error message either.

I am not sure that the server is correctly set up so any advice on what to look for/change would be greatly appreciate. Running CentOS 6.6 with Php 5.4