I'm trying to pipe an email to a php script. My test script is posted below. In my postfix alias file I have:
testuser: "|/usr/bin/php /usr/local/bin/stdin.php"
My script is:
#! /usr/bin/php -q
<?php
$fr = fopen("php://stdin", 'r');
$fw = fopen("result.txt", 'w');
$email = "";
while (!feof($fr))
{
$email = fgets($fr,4096);
fwrite($fw,$email);
}
fclose($fr);
fclose($fw);
?>
My permissions for the script are:
mail:/usr/local/bin administrator$ ls -al stdin.php
-rwxr-xr-x 1 administ wheel 512 Oct 26 08:40 stdin.php
When I try to pipe an email it appears not to get piped into the file. If I pipe a text file it works correctly:
mail:/usr/local/bin administrator$ cat input.txt | php stdin.php
Permissions problem? Am I missing something else? Is there a log file that I'm not aware of that could tell me why the email isn't getting piped in?
TIA,
Nick