# Email in Flash

**URL:** <https://forum.kirupa.com/t/email-in-flash/240475>\
**Category:** flash\
**Created:** [October 3, 2007, 11:34am UTC](https://forum.kirupa.com/t/email-in-flash/240475 "2007-10-03T11:34:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikneven](https://avatars.discourse-cdn.com/v4/letter/n/41988e/32.png) [@nikneven](https://forum.kirupa.com/u/nikneven)\
**Post date:** [October 3, 2007, 11:34am UTC](https://forum.kirupa.com/t/email-in-flash/240475/1 "2007-10-03T11:34:09Z")

</div>

ok, so i have a script that i am using as an email/php form on my site. It all works out fine when tested locally, but for some reason, i cant get it to work on the server. and yes, the server does run php mail stuff. unless there is some php server thing to use loadandSend. here’s the actionscript.

```auto
stop();
this.closer.onRelease = function() {
    play();
};
var contact_php_file = "flashEmailer.php";
send_btn.onRelease = function() {
    checkForm();
    form.msg_txt.setEnabled(false);
    form.name_txt.setEnabled(false);
    form.email_txt.setEnabled(false);
    send_btn.enabled = false;
};
function checkForm() {
    n = form.name_txt.text;
    e = form.email_txt.text;
    m = form.msg_txt.text;
    if (m != "" && e != "" && n != "") {
        sendEmail(n, e, m);
    } else {
        _level0.myMCL.loadClip("1.swf", 6);
        trace("All Required Fields Not Filled In!");
    }
}
function sendEmail(n, e, m) {
    //session = "?nocache=" + random(999999);
    contact_lv = new LoadVars();
    contact_lv.name = n;
    contact_lv.email = e;
    contact_lv.message = m;
    contact_lv.key = "email";
    trace(n+" - "+e+" - "+m);
    contact_lv.sendAndLoad("flashEmailer.php", contact_lv, "POST");
    contact_lv.onLoad = function(success) {
        if (!success) {
            return trace("Error calling PHP File!");
            _level0.myMCL.loadClip("3.swf", 6);
        } else {
            _level0.myMCL.loadClip("4.swf", 6);
            return trace("Email Sent!");
        }
    };
}

```

and here is the php…

```php
<?php

$recipients = "myemail@gmail.com" . ",";
$subject = "The Message";

// Grab the key from Flash to ensure security
$sendKey = $_POST['key'];

// Only allow the page to send if Flash is the requester
if($sendKey == "email") {
    // The following three variables are gathered from Flash
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    
    // Grab todays date
    $date = date("F j, Y", time());

    // This block is the actual message that is sent in the email
    $email_info .= "Below is the visitors contact info and message.

";
    $email_info .= "Visitor's Info:
";
    $email_info .= "-----------------------------------------
";
    $email_info .= "Name: " . $name . "
";
    $email_info .= "Email: " . $email . "
";
    $email_info .= "Date Sent: " . $date . "

";
    $email_info .= "Message
";    
    $email_info .= "-----------------------------------------
";
    $email_info .= "" . $message . "
";

    $mailheaders = "From: webmaster@yourdomain.com <> 
";
    $mailheaders .= "Reply-To: " . $email . "

";

    mail($recipients, $subject, $email_info, $mailheaders);
?>

```

any ideas why it would run and return the “email sent” trace locally, but not on the server??? i’ve been up all night trying to figure this out.
