Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

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";
?>
[ Next Page ]

[Page 1]  [Page 2]  


Comments:
I need the Script to build a PHP MailerShola04/10/07 15:32
php mail Heinrich Mostert 06/15/05 10:00
Help : Automatic Email acccount Creation gladwin02/11/05 06:48
wanted php scriptsirish01/31/05 05:17
hello mesg to u dearEmad01/12/05 02:27
about mailsiri12/24/04 06:05
Selam-in aleykum kardesselim12/07/04 03:03
hellocetin07/24/04 09:32
Support systemGiancarlo06/24/04 03:08
Mailing listGiancarlo06/24/04 03:06
Usage of the programGiancarlo06/24/04 03:05
Unuseful codealejandro06/13/04 16:30
why this codding is not workingGovind Kumar Sahu05/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.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.