# Sending email from Flash

**URL:** <https://forum.kirupa.com/t/sending-email-from-flash/269868>\
**Category:** flash\
**Created:** [September 2, 2008, 3:35pm UTC](https://forum.kirupa.com/t/sending-email-from-flash/269868 "2008-09-02T15:35:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![megalord](https://avatars.discourse-cdn.com/v4/letter/m/e8c25b/32.png) [@megalord](https://forum.kirupa.com/u/megalord)\
**Post date:** [September 2, 2008, 3:35pm UTC](https://forum.kirupa.com/t/sending-email-from-flash/269868/1 "2008-09-02T15:35:47Z")

</div>

OK, my problem is simples. I want to be able to send an email directly from a Flash animation using an external php file. This email will have the datas I insert in a few text boxes.

In AS2 I had no problem doing this… AS3 is presenting me a chalenge.

Here is the code I have so far:

AS3

```auto
var loader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest("[email.php](http://www.martingunnarsson.se/flashtest/send.php)");
var variables:URLVariables;
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
req.method = URLRequestMethod.POST;
 
sender.addEventListener(MouseEvent.MOUSE_DOWN, sendForm);
 
function sendForm(evt:MouseEvent):void {
   variables.theName = theName.text;
   variables.theEmail = theEmail.text;
   variables.theMessage = theMessage.text;
   req.data = variables;
   loader.load(req);
   }
}

```

PHP

```auto
<?PHP
$theName = $_POST['theName'];
$theEmail = $_POST['theEmail'];
$theMessage = $_POST['theMessage'];
$to = "[EMAIL="email@email.com"]email@email.com[/EMAIL]";
$subject = "wathever subject";
$message = "Name: " . $theName;
$message .= "
Email: " . $theEmail;
$message .= "

Message: " . $theMessage;
$headers .= "From: $theEmail";
$headers .= "
Reply-To: $theEmail";
mail($to,$subject,$message,$headers);
?>

```

can some one find my mistake?
