I've been trying to pipe incoming emails to a php script for the past one week but to no avail. I've tried my level best. Googled around.. read dozens of articles... followed all instructions YET fail to achieve this. If anyone can PLEASE help me with this.... Here are the details.
I want an email sent to upload@mydomain.com run a file /var/websites/mydomain.com/default.php
I've made the following modification in /etc/aliases
[quote]upload: "|/var/websites/mydomain.com/default.php"[/quote]
executed 'newaliases' for it to take effect.
My php script which is located at /var/websites/mydomain.com/default.php is THIS
CODE
#!/usr/local/bin/php -q
<?php
$ifp = fopen('hello.txt', "wb");
fwrite($ifp, 'Yo');
fclose($ifp);
?>
<?php
$ifp = fopen('hello.txt', "wb");
fwrite($ifp, 'Yo');
fclose($ifp);
?>
As you can see upon execution, this should create a hello.txt file in the same directory i.e. /var/websites/mydomain.com/hello.txt
I've also done THIS to give send mail root shell access to php.
[quote]ln -s /usr/local/bin/php /etc/smrsh/php[/quote]
Now Finally upon sending an email, the script isn't being executed and i get the following message:
[quote]Sep 18 20:37:00 vps sendmail[15158]: STARTTLS=server: file /etc/mail/certs/cert.pem unsafe: No such file or directory
Sep 18 20:37:00 vps sendmail[15158]: j8IJb0MM015158: from=<zain@alizafar.net>, size=1198, class=0, nrcpts=1, msgid=<000901c5bc88$56ae8820$0100a8c0@p4>, proto=ESMTP, relay=acer.digitallinx.com [72.36.167.106]
Sep 18 20:37:01 vps sendmail[15165]: j8IJb0MM015158: to="|/var/websites/mydomain.com/default.php", ctladdr=<upload@mydomain.com> (8/0), delay=00:00:01, xdelay=00:00:01, mailer=prog, pri=31407, dsn=2.0.0, stat=Sent
[/quote]
Please if anyone can help..
O.S.: Fedora Core 2
MTA: Sendmail