I have reviewed all the advice I could find on piping mail to PHP. I have tried to duplicate the setup described here as closely as possible:
I can’t make it work. Pardon if I have missed something obvious, I’m a newbie with the Unix shells.
So, preparing for this I have copied the php binary and the libraries it depends on to my $HOME/handlemail/php-bin folder.
I tried to write a shell script that would set the LD_LIBRARY_PATH variable and call the PHP file. I first tried a .forward.postfix that would pipe the mail directly to the shell script (not using procmail):
This script contained two lines:
Unfortunately it’s just a black hole - no error messages. No output from the script.
I’ve also tried to add a #! - line to the PHP script and use only the path and file name. This causes a peculiar set of error messages:
Command output: …/email.php:
?php: No such file or directory …/email.php: line 3: syntax
error near unexpected token `include(’./php-lib/log.php’)’
The ?php: stuff sounds like the script tried to execute this as a shell script and took the <?php to be a file redirection thing. (Googled those errors but found no solutions, only questions).
Finally, I’ve tried using procmail as described in the article and I get the same thing: no error messages, the procmail logfile says it executed the command, includes no errors - but there is no evidence that the script has actually ran.
The only way I can make it work is to telnet into the server, change to the folder where the PHP binary is installed, and pipe some input to the command “php …/email.php”. Then the script runs and does what I expect. If I try the same thing in my $HOME folder with the complete paths it fails silently. I tried to write a shell script that changes to the php-bin folder and runs the command like that but no luck with that either. (I’m not sure if I need to do something extra to make STDIN available to a command called from a shell script though - that’s how newbie I am with all this… ;p )
Does this ring a bell with anyone?