Search results for 'Mozala'. 1 post(s) found.
When you need to get content with POST Method in PHP internal code, you need to get the desired result through alternate Socket Programming as below.
Actualluy what I wanted is emailing through alternate server located in different domain, because the current server has some limitation.
Following code is implemented at caller server.
<?
// caller page : kmail.php
// programmed by Super Coder / Chunun Kang (kurapa@kurapa.com)
function kmail( $recipient, $subject, $body)
{
$host = "foo.com";
$uri = "/api/kmail_api.php";
// acutally security code is removed on below code.
// you can add it by yourself.
$reqbody = "s=" . urlencode($subject)
. "&b=" . urlencode($body)
. "&f=" . urlencode('SAMSUNGDForum')
. "&h=" . urlencode($headers)
. "&r=" . urlencode($recipient);
$contentlength = strlen($reqbody);
$reqheader = "POST $uri HTTP/1.0\xd\xa".
"Host: $host\xd\xa". "User-Agent: Mozala\xd\xa".
"Content-Type: application/x-www-form-urlencoded\xd\xa".
"Content-Length: $contentlength\xd\xa\xd\xa".
"$reqbody\xd\xa";
$socket = fsockopen($host, 80, $errno, $errstr);
if (!$socket)
{
$result["errno"] = $errno;
$result["errstr"] = $errstr;
return $result;
}
fputs($socket, $reqheader);
while (!feof($socket))
{
$result[] = fgets($socket, 4096);
}
fclose($socket);
return $result;
}
?>
// caller page : kmail.php
// programmed by Super Coder / Chunun Kang (kurapa@kurapa.com)
function kmail( $recipient, $subject, $body)
{
$host = "foo.com";
$uri = "/api/kmail_api.php";
// acutally security code is removed on below code.
// you can add it by yourself.
$reqbody = "s=" . urlencode($subject)
. "&b=" . urlencode($body)
. "&f=" . urlencode('SAMSUNGDForum')
. "&h=" . urlencode($headers)
. "&r=" . urlencode($recipient);
$contentlength = strlen($reqbody);
$reqheader = "POST $uri HTTP/1.0\xd\xa".
"Host: $host\xd\xa". "User-Agent: Mozala\xd\xa".
"Content-Type: application/x-www-form-urlencoded\xd\xa".
"Content-Length: $contentlength\xd\xa\xd\xa".
"$reqbody\xd\xa";
$socket = fsockopen($host, 80, $errno, $errstr);
if (!$socket)
{
$result["errno"] = $errno;
$result["errstr"] = $errstr;
return $result;
}
fputs($socket, $reqheader);
while (!feof($socket))
{
$result[] = fgets($socket, 4096);
}
fclose($socket);
return $result;
}
?>
In addition you need to add following callee PHP page on your callee server.
<?
// callee page : /api/kmail.php
// programmed by Super Coder / Chunun Kang (kurapa@kurapa.com)
$title = '=?utf-8?b?'.base64_encode($s).'?=';
$recipient = $r;
if (strlen($h)<1)
{
if (strlen($f)>0)
{
$h = "From: $f <no-reply@foo.com>\r\n";
}
else
{
$h = "From: NO-REPLY <no-reply@foo.com>\r\n";
}
$h .= "X-Sender: no-reply@foo.com\r\n";
$h .= "X-Mailer: Mozala PHP ".phpversion()."\n";
}
mail($recipient , $title, $b, $h);
?>
// callee page : /api/kmail.php
// programmed by Super Coder / Chunun Kang (kurapa@kurapa.com)
$title = '=?utf-8?b?'.base64_encode($s).'?=';
$recipient = $r;
if (strlen($h)<1)
{
if (strlen($f)>0)
{
$h = "From: $f <no-reply@foo.com>\r\n";
}
else
{
$h = "From: NO-REPLY <no-reply@foo.com>\r\n";
}
$h .= "X-Sender: no-reply@foo.com\r\n";
$h .= "X-Mailer: Mozala PHP ".phpversion()."\n";
}
mail($recipient , $title, $b, $h);
?>
Finally what you need to do is including above caller page to call kmail function.
include "./kmail.php";
kmail( "foo@foo.com", "howdy?", "test message from Chunun Kang (kurapa@kurapa.com");
kmail( "foo@foo.com", "howdy?", "test message from Chunun Kang (kurapa@kurapa.com");
Another posts included in "PHP"
| PHP function converts new line to BR tag (0) | 2009/11/27 |
| How to remove HTML tags in text string? (0) | 2009/08/05 |
| How to delete file on certain path ? (0) | 2008/10/01 |
| ASCII Artwork Generator from image file (0) | 2008/09/23 |
| How to limit by Timeout when opening URL ? (0) | 2008/04/14 |
| How to put timeout when opening URL by fopen ? (0) | 2008/03/31 |

Prev

Rss Feed