Help - Search - Members - Calendar
Full Version: Piping Emails To Php Script
Linuxhelp > Support > Programming in Linux
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 run a file /var/websites/

I've made the following modification in /etc/aliases
[quote]upload:      "|/var/websites/"[/quote]
executed 'newaliases' for it to take effect.

My php script which is located at /var/websites/ is THIS
#!/usr/local/bin/php -q
    $ifp = fopen('hello.txt', "wb");
    fwrite($ifp, 'Yo');

As you can see upon execution, this should create a hello.txt file in the same directory i.e. /var/websites/

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=<>, size=1198, class=0, nrcpts=1, msgid=<000901c5bc88$56ae8820$0100a8c0@p4>, proto=ESMTP, []
Sep 18 20:37:01 vps sendmail[15165]: j8IJb0MM015158: to="|/var/websites/", ctladdr=<> (8/0), delay=00:00:01, xdelay=00:00:01, mailer=prog, pri=31407, dsn=2.0.0, stat=Sent

Please if anyone can help..
O.S.: Fedora Core 2
MTA: Sendmail
The easisest way to do so, is to use a .forward file. The email can be piped to a prcess and read fromSTDIN (php://stdin can be sued just like a regular file, ie with fopen and fgets)

There is quite a lot of info, i'll have a look through my bookmarks and see if i can find the site I use

* Moving to Programming Section *

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.