我使用閃光燈CS6和Flash Player 11.4AS3發送使用PHP
這裏電子郵件的例子從發送電子郵件閃存使用PHP
AS3代碼:
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代碼:
<?php
$msg = $_POST["msg"];
$to = "[email protected]";
$subject="Message from php";
$success = mail($to,$subject,$msg,"Content-Type: text/plain; charset=utf-8");
echo "temp=1&success=".$success;
?>
一切都看起來很簡單,但沒有工作
1)響應:應該是真的還是假的,是:」 $成功; ? >(?壞解析)
2)e.target.data看起來怪怪的:
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)執行代碼,我沒有收到任何電子郵件....一定出事了之後?
你的網絡服務器有問題(如果你有一個問題),因爲php沒有執行。你應該知道,你不能在沒有Web服務器的情況下運行一個php腳本。 – akmozo