Re: How retrieve database data from email?
| From: | Bogdan Stancescu | Date: | Fri, 16 Aug 2002 15:27:49 +0000 |
| Subject: | Re: How retrieve database data from email? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112972@lists.php.net to get a copy of this message | ||
I'm not very proficient with e-mail configuration, so if someone finds I'm saying something wrong, don't think twice before correcting it. AFAIK, you can create an alias typically in /etc/aliases - or /etc/sendmail/aliases, as I've heard for newer versions of sendmail. In any case, the file has to be there already because that's where you have the root/webmaster/postmaster aliases defined.
Add a line reading
stocks: | /usr/bin/php /path/to/your/script.php
I'm not sure if sendmail should be restarted after this, so you'd better do it just to make sure.
You'll obviously need root access to do these. After this point, you don't anymore.
In /path/to/your/script.php, you'll receive the whole e-mail message from standard input, so you'll have to check out those functions here http://www.php.net/manual/en/features.commandline.php
Then all you have to do is parse the incoming mail message - I'm sure you'll be able to google out plenty of functions/classes to do that - drop me an e-mail if you don't find any and I'll send you mine.
Bogdan
Lallous wrote:
How and where can I add an alias and associate PHP with that alias? Elias "Bogdan Stancescu" <mgv@canad.ro> wrote in message news:3D5C4F78.3070700@canad.ro...You can set up php to run from console if it doesn't already, and add an alias to your mail server ("stocks") which would parse the incoming mail and do the appropriate deeds. Bogdan M wrote:Hello People: I have my pages built in PHP / Mysql, all working ok, but now I need solve a problem I don't know how to solve or even how search about. Case this problem was already discussed in this list, I would be grateful if someone pass to me correct date so I can search about. My problem is very simple: I have customers who dont want enter into html pages to retrieve some info (suppose info are stock values), but rather they want to send email with formatted query into mail subject (or at least in body) , and then receive response again by email. For instance, customer could send this for stocks@alpha.com to: stocks@alpha.com subject: name=ibm, year=2001 body: (empty) In response, he should receive an email with all IBM stock prices day by day. That't all, I hope this will have solution, but I can't figure how email could communicate automatically with PHP/Mysql. Thanks Miguel