Thanks Michael!!

This process is something really new to me and sounds like there is much to
learn abt. Thanks for the guide.

Can I also request that you send the perl equivalent script that you have
written to me to [EMAIL PROTECTED] please? Thank you very, very
much =)


kokboon

-----Original Message-----
From: Michael Sims [mailto:[EMAIL PROTECTED]] 
Sent: 09 January 2003 11:49
To: [EMAIL PROTECTED]
Cc: See kok Boon
Subject: Re: [PHP] how to make server response to emails

On Thu, 9 Jan 2003 17:33:02 +0800, you wrote:

>I believe
>that there is a way to make the mail server, or which ever it is, to
>response specifically to text within the mail.
[...]
>However, I have no idea how this is accomplished and what this system is
>called, so I need some precious help here. Anyone please?

99% of the time scripts such as this operate in the following manner.
Lets say the script responds to emails sent to [EMAIL PROTECTED]  The
server which handles mail for example.com has an alias for the address
"foo" which actually points to an external script.  Most MTA's will
allow you to do this (yes, even some for Windows, believe it or not).
For example, in sendmail you could place a line in /etc/aliases or
/etc/mail/aliases (depending on your installation) like the following:

foo:  "|/usr/local/bin/myscript.php -s"

This would cause sendmail to send the text of any email sent to "foo"
to myscript.php's stdin via a pipe.  (Be aware that some sites with
sendmail use the sendmail restricted shell, so there are some extra
steps involved in getting an alias like the above to work, which I
won't go into here).

"myscript.php" would need to be a PHP CLI script, meaning that it's
chmod'ed executable and has:

#!/usr/local/bin/php

at the top or something similar.  Then this script would have to read
from stdin and parse the text it receives via regexes or some other
method to determine how to handle it.  The script would receive the
full message, including all headers.

In PHP you can read from stdin by opening a filehandle to it:

$stdin = fopen('php://stdin', 'r');

Although in PHP 4.3.0 there are CLI specific constants defined which
obseletes the above.  For more info:

http://www.php.net/manual/en/features.commandline.php

I've implementing a script like this before, but unfortunately it's
written in Perl.  Many of the concepts are similar, though, so if you
know any Perl at all and think it may help you I can send it to you
off-list.

HTH...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to