mercredi 1 mars 2017

ActionScripts 3 to PHP email send

I found a tutorial for send email using actionscripts 3 and php, i downloaded project files and copied mail.php to our VPS server xamp htdocs folder. Animate CC project run but nothing sent.

AS3:
submit_btn.addEventListener(MouseEvent.CLICK, sendMessage);
function sendMessage(e:MouseEvent):void
{
    var my_vars:URLVariables = new URLVariables();
    my_vars.senderName = name_txt.text;
    my_vars.senderEmail = email_txt.text;
    my_vars.senderMsg = message_txt.text;

    var my_url:URLRequest = new URLRequest("http://ift.tt/2lqVKIq");
    my_url.method = URLRequestMethod.POST;
    my_url.data = my_vars;

    var my_loader:URLLoader = new URLLoader();
    my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    my_loader.load(my_url);

    name_txt.text = "";
    email_txt.text = "";
    message_txt.text = "Message Sent";
} 

PHP:

<?php
$to = "emaill@yourDomain.com";
$subject = ($_POST['name']);
$message = ($_POST['message']);
$message .= "\n\n---------------------------\n";
$message .= "E-mail Sent From: " . $_POST['name'] . " <" . $_POST['email']  . ">\n";
$headers = "From: " . $_POST['name'] . " <" . $_POST['email'] . ">\n";
if(@mail($to, $subject, $message, $headers))
{
    echo "answer=ok";
} 
else 
{
    echo "answer=error";
}
?>

Aucun commentaire:

Enregistrer un commentaire