I am using postfix and procmail. But I have a problem with procmail and php.
The php-code /home/www/cron/mail_visirun.php
run without any problem, but if /home/www/cron/mail_selva.php
shoud be run on the logfile comes an error message:
My procmail file:
My php file /home/www/cron/mail_selva.php
:
LOGFILE=/var/log/procmailrc.log
VERBOSE=yes
ATTACHinvoice=`echo /home/dok/dispo/RGein`
ATTACHselva=`echo /home/dok/dispo/Selva`
:0
* ^From:.*visirun
| /usr/bin/php /home/www/cron/mail_visirun.php
:0c
* ^To.*[email protected]
! [email protected]
:0
* ^To.*[email protected]
| munpack -q -C $ATTACHinvoice
:0c
* ^From:.*selva
! [email protected]
:0c
* ^From:.*selva
| munpack -q -C $ATTACHselva
:0
* ^From:.*selva
| /usr/bin/php /home/www/cron/mail_selva.php
:0
* ^To.*[email protected]
| /usr/bin/php /home/www/cron/mail_selva.php
:0 w
! [email protected]
The php file /home/www/cron/mail_selva.php
:
<?php
echo "OK";
?>
My logile:
procmail: Executing "/usr/bin/php,/home/www/cron/mail_selva.php"
procmail: Error while writing to "/usr/bin/php"
procmail: Assigning "LASTFOLDER=/usr/bin/php /home/www/cron/mail_selva.php"
I can not understand why one script run and another script give an error.
The error is that your PHP script fails to read its standard input. Procmail detects this, and regards the delivery as unsuccessful.
If the plan is for the script to do something useful with its standard input, just do that, and the error will go away.
If not, maybe explain in more detail (probably in a new question by now) what your script does and what you hope should happen when Procmail pipes the current message into it.
Stylistic remarks:
echo
in backticks. Changevariable=`echo value`
tovariable='value'
(possibly without the quotes, if the value does not require quoting).w
flag on the final recipe is weird. I'm not sure what you could expect that to do. What is your intention?Then you're still stuck with the
^To.*[email protected]
with an identical delivery action. Maybe things could still be refactored.