AS2 Flash Contact Form
Here is a working example of flash contact form with simple validations using ActionScript 2 and PHP mail function. This flash email form can also immediately response back to you if the email was sent successfully or failed. You can easily copy the contact form movie clip and paste it into an empty frame of any flash template.
You need to replace below red line with your email address in send_email.php file.
$receiver = “youremail@yourdomain.com”;
If your web server does not support PHP, you will need to use any other supported server side language for mail function instead of using send_email.php file.
UPDATES (24 June 2008): Adding Email Auto Response in send_email.php file
-
<?php
-
$contact_name = $_POST[‘name’];
-
$contact_email = $_POST[‘email’];
-
$contact_subject = $_POST[’subject’];
-
$contact_message = $_POST[‘message’];
-
-
if( $contact_name == true )
-
{
-
$sender = $contact_email;
-
$receiver = “youremail@yourdomain.com”;
-
$client_ip = $_SERVER[‘REMOTE_ADDR’];
-
-
$email_body = “Name: $contact_name \nEmail: $sender \nSubject: $contact_subject \nMessage: $contact_message \nIP: $client_ip \nFlash Contact Form provided by http://www.flashmo.com”;
-
$email_body_auto_reply = “Hello $contact_name, \nThis is the auto reply message. Thank you. \nAdmin – http://www.flashmo.com”;
-
-
$extra_auto_reply = “From: $receiver\r\n“ . “Reply-To: $receiver \r\n“ . “X-Mailer: PHP/” . phpversion();
-
-
mail( $sender, “Auto Reply – Re: $subject”, $email_body_auto_reply, $extra_auto_reply ); // auto reply mail to sender
-
-
{
-
echo “success=yes”;
-
}
-
else
-
{
-
echo “success=no”;
-
}
-
}
-
?>
UPDATES (22 July 2008): Error correction in send_email.php file
Please change $subject to $contact_subject in line number 15.
Feel free to drop a comment if you have any question or feedback.
Related Post: Flash Contact Form in ActionScript 3





do you have an asp version of this code? My server supports asp but not php
Dear administrator, I have a question: why in the SEND actions I cannot take away the FLASHMO word as shown below? If I do it, the form doesn’t work anymore
send_email.php?flashmo=
sorry, I fixed it up.. I took out also the question mark symbol!!
I’ve done everything you said i had to do but it doesn’t work. I gives the message that the mail wasn’t delivered.
Works a treat…check out my version at
http://www.4reeldigitalart.com. I changed the fonts & color scheme to suit my site..It took all of 5 minutes to give it a make-over…(I might just change the red ’sending message’ text now that I know it works..10/10
Wonderful stuff OP.
The FOX
is there a way that i can edit this and make like a reservation page using this contact form
Hello, I am Brazilian, excuse me for the mistakes of writing!
Because this form is not working on my jobs?
I can not understand!
This doesn’T work for me at all
I always get the message “Your message could not be sent. Please try again.”
I have unzipped the folder, then changed adress in .php file, saved and uploaded to my server (yes, it has php).
What could be wrong?
mine still says sending… i’ve done everything everyone says in this comments page,
i’ve updated everything it still gets stuck on sending…
when i publish it ni html
Hello ..
I have been using this feedback form b4 as well .. not tat dumb wit flash i am .. but suddenly all the feedback forms tat i hav done or am oding arent working .. chk http://www.pencilatwork.com click on feedback .. it sends succefully .. but a mail is neva delivered .. i am really stuck .. http://www.pencilatwork.com/flashmo .. i uploaded the whole package .. just changed the email add in the php file .. still doesnt work . ??? urgent help needed ..
the form works…it says sent….but I do not get the mail at all……help…is the reciever line in the php file the ONLY line that needs to be modified or are thier others…
We are using a server which doesn’t support PHP. How would we be able to use your contact form? Do you have an HTML file that will work?
I worked a little and now I can run PHP on my server sooo scratch the one before xd, I just have one more problem… In the remote ADDR, should I be putting my IP adress?
i have tried on 3 different servers man .. all support php .. all running heavy CMSs .. still the fucking thing doesnt work .. am in deep trouble over this guys . i am a designer .. i understand least of this codeing .. at least php n all .. plz lemme know if you find a solution ..
thanks in advance
And the thing is .. that it was working few months back all so perfect .. suddenly by itself it stopped ..
may tat AC_RunActiveContent javascript file gotta do something wit it … is it?? tat looks like greek
Is this free to use on business/commercial sites?
Hi all,
First of all, I would like to say that this form is really cool. For those of us that are NOT programers, just designers…this helps alot.
Here is the two real problems that I and I assume most of the people on this forum are going to have is 1) That if the hosting server does allow PHP scripting…you may need to contact them to verify that the PHP extentions on thier end are turned ON. (this was the case with my ISP COMCAST…the support was there, just not enabled on thier end.) and 2) that the code does not allow for SMTP authentication…which is used by may servers that we host on..Mine is COMCAST (said with extreme hatered). These idots keep bouncing around the issue. I am NOT a programmer…so I have no idea how to itegrate thier SMTP sample code into the functioning code you have with this file… below is what my site looks like…the contact form script works, but does not recieve on my end…meaning the mail is never really sent..the script just SAYS it is…
Check out the site…so you can see what I mean.
http://www.fixitonsite.comcastbiz.net/
robert.downey@fixitonsite.comcastbiz.net
Now here is the sample they used to send a test mail to me…(which by the way how do you run a test, and what program or site would you use to do that):
<?php
require_once “Mail.php”;
$from = “Your Server “;
$to = “Robert Downey “;
$subject = “Hi Robert – Server Email Test!”;
$body = “Hi,\n\nHow are you? If you can see this the email script works.”;
$host = “smtp.jackiechantastic.com”;
$port = “587″;
$username = “test@jackiechantastic.com”;
$password = “test123″;
$headers = array (‘From’ => $from,’To’ => $to,’Subject’ => $subject);
$smtp = Mail::factory(’smtp’,array (‘host’ => $host,’port’ => $port,’auth’ => true,’username’ => $username,’password’ => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail))
{
echo(“” . $mail->getMessage() . “”);
}
else
{
echo(“Message successfully sent!”);
}
?>
First off…what the hell is the require once mail_php or whatever mean…I have no file called that…
Second off…again how can this script example intergrate with you form to actually work…when I try using ANY variation of this with the original code (I have tried many)…the screen will just say sending…
that’s it.
HELP!!
I got this working…for those of us out there that are NOT programers here is the final code that I am using without the auto reply (have add that still. AGAin I am on Comcast, so some of the in for like user name and pass on’t apply to you, but this is what it took to get the damned thing to work.:
<?php
require_once “Mail.php”;
$to = “Robert Downey “;
$message_name = $_POST['name'];
$message_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];
$host = “smtp.fixitonsite.comcastbiz.net”;
$port = “25″;
$username = “robert.downey@fixitonsite.comcastbiz.net”;
$password = “Darkside1″;
$headers = array (‘From’ => $message_email,’To’ => $to,’Subject’ => $contact_subject); $smtp = Mail::factory(’smtp’,array (‘host’ => $host,’port’ => $port,’auth’ => true,’username’ => $username,’password’ => $password));
$mail = $smtp->send($to, $headers, $contact_message);
if (PEAR::isError($mail))
{
echo(“” . $mail->getMessage() . “”);
}
else
{
echo(“Message successfully sent!”);
}
?>
As you can see it does look a little different from the original script. I took the contact form fields and renamed the first two (in flash action scripts, the button names, and the php…or this won’t work.), Then I placed the $to so that it will alwasy go to me…for the smtp mail factory you see that I had to add the smtp server name, username password AND port…this is a default port so it should work for you too….that or port 587……The only field that does not populate with this modified script is the messag_name field from the form. But I don’t care, I got the email address, suject and the message field working. The only error or problem I had is the action script that tells the user the message was sent still doesn’t work but I get messages, adn can reply back to them (I used 2 different accounts to test it and it works great…so I next went into the action script for the form and looked for the “sending…” message and changed it to say “your message was sent, please press CLEAR to reset the form. that was it…When I get the auto reply working I will place the code here to help out…
Check out what I have at
http://www.fixitonsite.net
Hello!
I am trying to use this form and send text in Greek language but it does not work (we receive the text-email in unreadable characters). Is there a way to send it UTF-8 or ISO? Thank you.
Hey there,
Thank you so much for this post. Like the others I am stuck on sending…. GoDaddy is hosting. They do support php and I have called in and it is activated on their end.. Any ideas of what could be happening???
I am not getting any errors and I am not getting any emails. I get the confirmation that it was sent but no email. I am using php 4.0 with godaddy.com as my hosting. the example is here
http://www.kingdomleaders.org/contacts.html
(click “worship leader”)
Thanks for any help.
UPDATE: I got the email 2 hours later so there was no problem with the script. I will try the auto-reply now.
Thanks everyone for this great tutorial
hey guys here is the final code now that I got all fields to email (finally).
any way here it is. Also a side note. I had to set the $from AND the $to to MY email…as the comcast servers will think that I was trying to use thier servers to send another carrriers mail otherwise.. here you go…don’t forget to check the final product too.
http://www.fixitonsite.net
<?php
require_once “Mail.php”;
$from = “ADMIN “;
$to = “Robert Downey “;
$cc = $message_email;
$message_name = $_POST['name'];
$message_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];
$body = “Name: $message_name \nEmail: $message_email \nSubject: $contact_subject \nMessage: $contact_message \nIP: $client_ip”;
$extra = “From: $from\r\n” . “Reply-To: $message_email \r\n” . “X-Mailer: PHP/” . phpversion();
$host = “smtp.fixitonsite.comcastbiz.net”;
$port = “587″;
$username = “robert.downey@fixitonsite.comcastbiz.net”;
$password = “Darkside1″;
$headers = array (‘From’ => $from,’To’ => $to,’Subject’ => $contact_subject,’Cc’ => $message_email);
$smtp = Mail::factory(’smtp’,array (‘host’ => $host,’port’ => $port,’auth’ => true,’username’ => $username,’password’ => $password));
$mail = $smtp->send($to, $headers, $body, $extra);
if (PEAR::isError($mail))
{
echo(“” . $mail->getMessage() . “”);
}
else
{
echo(“Message successfully sent!”);
}
?>
first 2 lines should read like this:
$from = “ADMIN “;
$to = “Robert Downey “;
where the ADMIN is your email ex..
sample@emailaccount.com
make sure the admin address is in quotes…
email me at robertd0275@yahoo.com if you need the full send_mail.php if you are having trouble…
here is my question…for some reason…the message will NOT clear after it is sent…so as a temp solution, I changed the sending…text to say Message sent.
the form does not clear unless I press the reset button…what does the action script need to say so that the message will read message sent, and then automatically clear regardless of whether the message WAS SENT!!…it seem the the AS2 script for the verify then clear..does not work for me SO i want to take it out…what can I change to do this?
any1 figured how to fix the “sending” prob yet? I’m still stuck
I have done everything except throw my computer out the window to get the email working. 427, 000 times we have done what it says and still I get the same fault time and time again.
Error opening URL ‘file:///C|/Documents%20and%20Settings/Darren/My%20Documents/Flash%204/send_email.php?flashmo=981′
If this gets any more frustrating I’m gonna start plucking my eyebrows out! HELP!!!!!!!!
Hi,
First of thanks for this tutorial!!!
Do you have a tutorial for a guestbook without components with custom buttons and fields?
Thanks!
UROCK!
i keep geting this error what does it mean
Error opening URL ‘file:///F|/final%20year%20project/website/send_email.php961′
Dazza,
Don’t pluck out youre eyebrows!!!
The salt in youre sweat is going to hurt youre eyes!!! they do have a function you know!
It doesnt work because youre trying it locally (youre cpu) Youre gonna have to put it online for it to work. And check if youre webserver allows PHP scripting.
Put youre swf and youre published html + the sendEmail.php in the same directory on youre server, it wont work from youre cpu.
dear admin
firstly, big thanks for your work but can i ask you
how can i sure that my server support php or not please reply
I´m getting the message “you message coul not be sent. Please try again”. I uploaded the .html, the swf, and send_email.php, and it doens´t work. Please HELP…
I also change “youremail@yourdomain.com”. Any idea?
Script works fine except I have to hit the send button twice, client will not like this . Any fix?
hey guys. GONZ, to run the PHP script by itself to test if your server TRULY supports php, all you need to do it go to the website that you published ..mine for example is http://www.fixitonsite.net….then put a forward slash / after the.net, and type in send_email.php…so it should look like this in my case:
http://www.fixitonsite.net/send_email.php
press enter…itf your server supports PHP, and you have changed the $recipeint = to your email address…it should give you a white screen that says…you message was sent successfully.
Check your email..you should have a blank message from yourself. that’s it.. Remember thought that some providers have not only the PHP but also SMTP authentication…like if you are hosting on COMCAST, COX, RoadRunner…etc. You will need to add lines to the PHP code for the SMTP authentication in that case. here is a heavily modified version of the original code for this form, it has the SMTP ion it…This form works perfectly…hit send once…that is it.
<?php
require_once “Mail.php”;
$from = “ADMIN “;
$to = “Robert Downey “;
$cc = $message_email;
$message_name = $_POST['name'];
$message_email = $_POST['email'];
$contact_subject = “New Mail From FIXITONSITE.net!!”;
$contact_message = $_POST['message'];
$body = “Name: $message_name \nEmail: $message_email \nSubject: $contact_subject \nMessage: $contact_message \nIP: $client_ip”;
$extra = “From: $from\r\n” . “Reply-To: $message_email \r\n” . “X-Mailer: PHP/” . phpversion();
$host = “smtp.fixitonsite.comcastbiz.net”;
$port = “587″;
$username = “robert.downey@fixitonsite.comcastbiz.net”;
$password = “Darkside1″;
$headers = array (‘From’ => $from,’To’ => $to,’Subject’ => $contact_subject,’Cc’ => $message_email);
$smtp = Mail::factory(’smtp’,array (‘host’ => $host,’port’ => $port,’auth’ => true,’username’ => $username,’password’ => $password));
$mail = $smtp->send($to, $headers, $body, $extra);
if (PEAR::isError($mail))
{
echo(“” . $mail->getMessage() . “”);
}
else
{
echo(“Message successfully sent!”);
}
?>
the auto reply is not supported in my version of php from my host…but the way this is written now…thier email info is also placed in the Cc field of the email I get…so I can reply to all and send them mail..also the body contains thier nam , email, and messge subject, and message body.
the $from= is ADMIN…which is set to
robert.downey@fixitonsite.comcastbiz.net placed in or:
ADMIN
there MUST be a space between the ADMIN and the first <…all of it should be inside one set of “”
the $to= is set to my email as well…so basically..I am sending a message to myself. Most hosts will BLOCK a message if the $from is set to the form’s email field address. This is because the host thinks that someone is trying to use your account to send out spams. by setting them BOTh to the same address manually. the Host doesn’t care.
As I said the code works…email me if you want the actual PHP file that I showed here. Ican help you set it up the way you need it. I also redesigned the form itself so that it is animated..which is cool as hell go look at my site and try it yourself.
My email is RobertD0275@yahoo.com for fastest resonse. Any of you needing help can send me a message there.
Hope this helps
Hi all,
I sent message then I’ll try to send again but When I click the SEND button I get an error “Your message couldn’t be send.Please try again.†Any idea?
and
loadVariables(“send_email.php?flashmo=” + random(1000), this, “POST”);
in this code what does 1000 means? do i need to change?
Thanks a lot…
Grek
not delivered help me admin
some body help me
sending. . .
after try again
your message send
but in fact its not delivered
why? help me
plush…it sounds like your server or host server i should say…is not letting the php script run…or it is not supported…
If it is supported…call your host and ask them to verify that the php server extentions for your site are enabled…the same thing happened to me and it turned out that they forgot to enable the feature on my account…after that it worked fine… email me at RobertD0275@yahoo.com and I can send you a test.php file that you can upload to your server or host…then all you need to do is type in a browser (for example)
http://www.fixitonsite.net/test.php
hit enter and if your host supports the PHP extention…it will say message was sent, and your email should have a blank message from your site…NO one ever told me these little tricks, had to learn it the hard way..
i have put swf,html,php form in the same directory in the server and php server scripting s on also.but the send form still doesn’t work.
i am gonna kill this computer
good computer is a dead computer
To all –
After three days of tryng to figure this out, I got mine to work. And because I’m a God fearing man, I’m going to share with the rest of the class.
First, if you’re like me you were unsure if your mail server was able to take PHP. Install PHP on your webserver (not your mail server). I found many sites to tell you what to do there. So far, all is well.
Second, if you’re like me you would eiher get the sending error forever or a message failed. odds are you’ve done something in the middle of that and you don’t know what it is. Let me tell you – from the box you were getting a “sending” after messing with the php file you got the message failed. The difference is that you changed the “youremail@yourdomain.com” to your actual settings. if you’re getting the sending message forever do this – type in http://%yourwebsaddress%/send_email.php.
If you get an error – congrats you’ve installed PHP if not. . .reconfigure your php.ini file to the recommend settings.
NOW for the fix – the problem (if you’re like me) you thought that when you changed “youremail@yourdomain.com” the php and flash was smart enough to figure out that “yourdomain” was were you wanted to relay off of. Not the case. Open the php.ini file and do a search for “SMTP.” that defaults to “localhost.” And if you’re like 80% of the planet your mailserver isn’t the same as your webserver. This was my problem. I changed local host to my pop3 server and – many happy dances – it worked.
Please let me know if this works –
Bill
hi bill.
how do i open the php.ini file ?
where is it?
do i need to go my web server control panel?
are you saying the send_email php script is correct?
plz let me know
i am just about get crazy about this form.
thank you
it just does not work! The demo code, even after changing the email address, does not work. YES I can run PHP (seriously, who can’t these days??)
I did notice a slight mistake in the send_email.php file – in line 4, there is a ‘ before sender when it should be a ` I even changed this and it still does not work.
Hey Reza –
The PHP.ini file should be in your program files, under PHP of the server that your website is on – again, NOT your mail server (unless they are the same).
Open it as a txt document from notepad.
I did have to restart IIS after I changed the PHP.
Yes, the script works (I do know how that sounds – a few days ago I would have called me a liar). Odds are your trying to relay off your local host (the ini’s default setting). Meaning that it’s just spooling trying to send. . .but doesn’t.
Stick it out – the beer after you realize the mistake is priceless.
Great tutorial, I’ve managed to get that working on one of my testing servers. I have a question though, it mentions in the tutorial that it has basic validation methods.
Is the form 100% bullet-proof with regards to getting spam, or can bots fill out Flash contact forms?
If so, how do I go about adding a CAPTCHA to the form?
Hi Admin, I’m like the rest of the people who is stuck on “sending…”
1. My web host is GoDaddy and I already double checked with them if they support PHP and they do. Its activated and everything.
2.I’ve put my index.html, swf, and send_mail.php in my root directory on GoDaddy.com
I don’t know what the problem is anymore. I really need your help. Thanks
Hi,
Nice form, can you upgrade it to send email with an attachment using AS2 ? any file format and work just like normail email attachment does? possible?
thanks