Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Piping Emails To Php Script, Help please
Zain
post Sep 18 2005, 04:31 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 1
Joined: 18-September 05
Member No.: 5,529



Hello,
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);
?>

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
Go to the top of the page
 
+Quote Post
DS2K3
post Sep 19 2005, 10:30 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,284
Joined: 14-November 04
From: Southampton, Hampshire
Member No.: 4,165



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 *

D


--------------------
Fixed your problem? Let us know!
richard@linuxhelp.net

www.Gathr.co.uk Online Event Management
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st October 2017 - 03:47 AM