I'm using flash CS6 and flash player 11.4
Here is the example sending email from Flash using PHP
as3 code:
var php_file = "simple_email.php";
var message_text = "Hello Im mesage from flash.";
function sendEmail():void
{
var myData:URLVariables = new URLVariables();
myData.msg = message_text;
var myRequest:URLRequest = new URLRequest(php_file);
myRequest.data = myData;
myRequest.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
try {
loader.load(myRequest);
} catch (error:Error) {
trace("Unable to load URL");
}
function completeHandler(e:Event):void {
trace("Data Content:"+e.target.data)
trace("Response:"+e.target.data.success);
};
};
sendEmail();
php code:
<?php
$msg = $_POST["msg"];
$to = "webhosting4@outlook.com";
$subject="Message from php";
$success = mail($to,$subject,$msg,"Content-Type: text/plain; charset=utf-8");
echo "temp=1&success=".$success;
?>
all is look simple, but not working
1) the Response: should be true or false and is:".$success; ?> (bad parsing?)
2) e.target.data looks strange:
Data Content:success=%22%20%24success%3B%0D%0A%3F%3E&%3C%3Fphp%0D%0A%09%24msg%20=%20var%5Fexport%28%24%5FPOST%2C%20true%29%3B%0D%0A%09%24to%20%3D%20%22baca%2Erene%40gmail%2Ecom%22%3B%0D%0A%09%24subject%3D%22Message%20from%20php%22%3B%0D%0A%09%24success%20%3D%20mail%28%24to%2C%24subject%2C%24msg%2C%22Content%2DType%3A%20text%2Fplain%3B%20charset%3Dutf%2D8%22%29%3B%0D%0A%09echo%20%22temp%3D1
3) After executing code I not received any email....something must be wrong?