Re: Automatic incoming mail notification
| From: | Steve Werby | Date: | Fri, 02 Feb 2001 05:53:55 +0000 |
| Subject: | Re: Automatic incoming mail notification | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-37793@lists.php.net to get a copy of this message | ||
"Josh G" <josh@gfunk007.com> wrote:
> Depends on your mailserver. Most mail servers can redirect incoming
> mail to a program, I know sendmail can. In your case just make the first
> line of your script #!/path/to/php/bin/php and that should do the trick.
To actually read from the message piped to the PHP script, you'll need to
use the following to read from STDIN:
fopen( 'php://stdin', 'r' );
The above isn't widely documented, but it works. With all this said, if the
original poster simply wants to let a web-based user know that there is a
new message in the user's email box, a better strategy may be to store all
of the messages in a database like MySQL and compare the timestamp on the
most recent message to the timestamp in a session variable from the previous
page access. It wasn't clear what the poster was attempting, but with some
more details someone (maybe me) could provide a good solution. Also, PHP
has functions for accessing IMAP accounts which could prove useful.
> Sorry I don't know how to make sendmail do it, only that you can.
Using sendmail you add an alias to pipe incoming email to a program (your
PHP script). You may also need to create a symbolic link in a directory
utilized by smrsh (sendmail restricted shell) to allow sendmail to execute
your script (this is done for security reasons). "man smrsh" for details.
--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/