Hello.
I have my .procmailrc file set up to pipe mail to a simple php script I've written. The only thing the script does at this point is echo back a "hello" message. However, procmail does not execute the script properly.
Here's my script (/home/webs/site.com/scripts/echo.php):
#!/usr/local/bin/php
<?php
echo "hi.";
?>
When I execute this script from the shell, it performs as expected. A message is echoed to the terminal ("hi.") and the script quits.
Here is my .procmailrc:
LOGFILE=/var/log/procmail.log
VERBOSE=YES
:0
| /home/webs/site.com/scripts/echo.php
And here is what is logged by procmail:
procmail: [11765] Fri Aug 6 16:12:48 2010
procmail: Executing "/home/webs/site.com/scripts/echo.php"
procmail: [11765] Fri Aug 6 16:12:48 2010
procmail: Assigning "LASTFOLDER=/home/webs/site.com/scripts/echo.php"
procmail: Notified comsat: "root@:/home/webs/site.com/scripts/echo.php"
From fodii2160@quicknet.nl Fri Aug 6 16:12:48 2010
Subject: Heard of the fellowship?
Folder: /home/webs/site.com/scripts/echo.php 728
/home/webs/site.com/scripts/echo.php: line 2: ?php: No such file or directory
/home/webs/site.com/scripts/echo.php: line 4: syntax error near unexpected token `newline'
/home/webs/site.com/scripts/echo.php: line 4: `?>'
procmail: [11769] Fri Aug 6 16:13:00 2010
procmail: Executing "/home/webs/site.com/scripts/echo.php"
/home/webs/site.com/scripts/echo.php: line 2: ?php: No such file or directory
/home/webs/site.com/scripts/echo.php: line 4: syntax error near unexpected token `newline'
/home/webs/site.com/scripts/echo.php: line 4: `?>'
procmail: [11769] Fri Aug 6 16:13:00 2010
procmail: Error while writing to "/home/webs/site.com/scripts/echo.php"
procmail: Assigning "LASTFOLDER=/home/webs/site.com/scripts/echo.php"
procmail: Locking "/var/mail/root.lock"
procmail: Assigning "LASTFOLDER=/var/mail/root"
procmail: Opening "/var/mail/root"
procmail: Acquiring kernel-lock
procmail: Unlocking "/var/mail/root.lock"
procmail: Notified comsat: "root@1356229:/var/mail/root"
From mudepeli7695@rr.com Fri Aug 6 16:13:00 2010
Subject: Intense - the secret
Folder: /var/mail/root
It appears that when procmail runs the script, the "#!/usr/local/bin/php" isn't recognized, so it's being run as if it's a shell script instead of using the php interpreter. This would explain errors such as "line 2: ?php: No such file or directory". (If you just run a php script from the command line without the path to the interpreter, that's exactly the kind of error you'll get).
I've tried modifying my .procmailrc file like so:
:0
| /usr/local/bin/php /home/webs/site.com/scripts/echo.php
(I removed the path to the interpreter from the script itself when running as above.) No joy. I'm at my wit's end here.
If the script were being executed properly, I would see the "hi." message being echoed back in procmail.log instead of the execution errors.
Help?