Re: php execution by email?
| From: | Michael Kimsal | Date: | Sun, 25 Jun 2000 02:48:39 +0000 |
| Subject: | Re: php execution by email? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-2947@lists.php.net to get a copy of this message | ||
It's possible, as I did it once before, but it's been awhile. You need PHP
as a CGI, not the module version, and I don't have that on my current
system. You'll also need to be able to route incoming emails
thru procmail or something like that. Route the emails to
the php script through a pipe. My procmail recipe is something like...
:0
* ^To: user@domain.com
{
:0 fhwc
| formail -k -X From: -X Subject: -X To:
:0 fc
|/usr/bin/perl /home/k-o/michael/public_html/cgi-bin/unsub.cgi
}
It's probably not the best example of a recipe, but it works. :)
You should be able to replace the /usr/bin/perl with
/usr/bin/php or whatever your PHP is, then pass it the
path and name of the file to execute.
In the example above, formmail is a system program which
takes the incoming mail and formats the first 3 lines into
From: fromaddress
Subject: subject
To: toaddress
Then the whole message follows. In perl, this is picked up thru
STDIN - this is the part I forget how to do in PHP. If you can
read the whole STDIN in PHP, you can read the email and
do what you want with it.
I used the above recipes to run perl scripts for triviabyemail.com
and inquiremail.com. It's one of the few things I still do in perl... :)
Chris Sano wrote:
> Does anyone know if it is possible to execute an PHP program with an email?
>
> For example, if I wanted to create a mail list manager and wanted it to send
> a mass email to all members on the list, could I send an email from Outlook
> to a specified URL and have it trigger the mass email?
>
> Has anyone done anything similar to tihs in the past?
>
> Chris
>
> ___________________________
> got sano? (new design!)
> http://www.rit.edu/~cms0670