|
Creating a PHP Script for Web Mail Posting and Notification
HOW IT WORKS
A PHP-Script is being called from the mailserver and receives the
incoming mail as standard-input. This mail is being forwarded to a URL via
HTTP-POST, such as a regular entry to a web formular. Also, because of the
.forward file you can forward the mail to other users automatically or you
can store it in a folder of your choice.
In order to start a PHP-Script from Postfix or sendmail, it has to be
processed just as a Shellscript. It should contain the directory of your
php-interpreter, such as:
#!/usr/local/bin/php
Even though many are just using PHP as an Apache-module, the interpreter
usually is installed in a self running file on the computer. On most
computers you can find it in /usr/local/bin/, on others you can find it
under /usr/bin/.
If you are labelling the created file as self-running (chmod a+x
scriptfilename) and then start it, your php-sourcecode in the shell -
just as a regular shellscript - should run.
OPEN THE ENVELOPE
Now we have to read out the standard input. As said above, Bjoern
already wrote about this, and it is just as easy as opening a file.
To be precise, a file such as "php://stdIn". This pseudo-URL allows
you to read out the standard input as follows:
<?php
$res="";
if ($fp=fopen("php://stdIn", "r"))
{
while (!feof($fp))
{
$line=fgets($fp, 4096);
$res.=$line;
}
fclose($fp);
}
echo "\n standard input was $res \n";
?>
| Comments: | ||
| I need the Script to build a PHP Mailer | Shola | 04/10/07 15:32 |
| php mail | Heinrich Mostert | 06/15/05 10:00 |
| Help : Automatic Email acccount Creation | gladwin | 02/11/05 06:48 |
| wanted php script | sirish | 01/31/05 05:17 |
| hello mesg to u dear | Emad | 01/12/05 02:27 |
| about mail | siri | 12/24/04 06:05 |
| Selam-in aleykum kardes | selim | 12/07/04 03:03 |
| hello | cetin | 07/24/04 09:32 |
| Support system | Giancarlo | 06/24/04 03:08 |
| Mailing list | Giancarlo | 06/24/04 03:06 |
| Usage of the program | Giancarlo | 06/24/04 03:05 |
| Unuseful code | alejandro | 06/13/04 16:30 |
| why this codding is not working | Govind Kumar Sahu | 05/24/04 04:18 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly. | ||


