PHPBuilder - Creating a PHP Script for Web Mail Posting and Notification Page 3



RSS Twitter
Articles Php Functions

Creating a PHP Script for Web Mail Posting and Notification - Page 3

by: Jochen Staerk
|
May 17, 2004

You could now parse the subject and the header-info, but the author likes to keep it general. My script collects the standard input and posts it to a URL such as it would be entered in a regular web form. In order to have it work for every application, we are not parsing. You could enhance the script so that every entry to the email header is being posted, such as it was an imaginary hidden field in a web formular. Doing this, you would make everything more complicated and you would specialize your application to email only.
POSTING OF THE CONTENT
There is a problem to run an HTTP-POST with PHP. PHP does not support that in the implemented scope of languate. The script from "nf@bigpond.net.au" (on nf.wh3rd.net/projects/http.inc/) emulates exactly this function, however.
It looks something like this:

<?php
$headers 
"POST &lt;URL&gt; HTTP/1.1\r\nConnection:
Keep-Alive\r\nUser-Agent: &lt;some faked user agent&gt;\r\nPragma:
no-cache\r\nCache-control: no-cache\r\nAccept: */*\r\nAccept-Language:
de,en,en-au\r\nHost: &lt;server&gt;\r\nContent-Type:
application/x-www-form-urlencoded\r\nContent-Length: &lt;length of  
urlencoded
length&gt;\r\n\r\n"
;

$fp fsockopen($server$port$errno$errstr);
if (!
$fp
{
    return 
false;
}

fputs($fp$headers);
fputs($fp$urlencoded);
$res="";
while (!
feof($fp)) $res.=fgets($fp1024);
// what the Server shows is now in $res
fclose($fp);
?>

« Previous Page
1
|
2
|
3
|
4
|
5
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Jochen Staerk

Comment:



Comment:

(Maximum characters: 1200). You have characters left.