PDA

View Full Version : problems with PHP mail from Flash



blue_muppet
February 28th, 2006, 08:25 AM
Hi there,

i have been searching high and low for a solution to my problem for about 2 days now, looking through site after site to find a way to get this working, and was hoping someone could help me out.

I have built an interactive mini-site, all in flash, and everything is working perfectly except for one thing: 'Send this to a friend'.

I need to create a simple mail form, preferably in PHP, that will send pre-defined text to the email address entered into the flash movie by the user, ie so they can send the link for the site to their friends.

an example of what i am aiming for is http://www.chimaira.com/chimaira/, after all the music and fun, they have a link 'send to', in whihc you can type a recipients details, and send them the link for the site.

i dont need anything quite so complex, i just need the user to enter an email address, and the message will be the same for all (i figure i can type this into a Dynamic text box hidden within the flash movie...).

can anyone help me with this?

txusm
February 28th, 2006, 09:40 AM
Hello blue_muppet, have you tried this tut?
http://www.thegoldenmean.com/technique/flashMX_mailform1.html

Txusm

blue_muppet
February 28th, 2006, 09:24 PM
Hi Txusm,

thanks for the link, but no, thats the only kind of tutorial i seem to be able to find.

I want the user to be able to input the email address that the message is going to, whereas those types of mail tutorials just send emails to the one address coded in the PHP.

Boerboel649
March 1st, 2006, 04:41 PM
Create an input text field, give it the instance name Semail. Then put the following code in your submit button.

on (release) {
if (Semail.text != "") {
loadVariablesNum ("email.php", 0, "POST");
gotoAndStop (2);
} else {
stop();
Serror._visible = true
}
}
That code says that if the field Semail has text in it, then to post the variable to email.php and go to and stop on frame 2 (frame two could have a message stating that the email has been sent or something like that.) If the field has no text in it, then it'll remain on frame one and make the movieclip Serror visible. (On my email from, Serror says "You must fill in all fields of the form!" you can make the error message say whatever you want it to.)
Now, for your php.


<?

$to = $email;
$subject = "Whatever you want the subject to be"
$msg = "Whatever you want the message to say";
mail($to, $subject, $msg, "From: youremail@yoursite.com");

?>
Make sure you save the php file as email.php and that it's in the same folder as the .swf

This ought to give you an idea of how to go about this. I didn't test it to see if it works, so let me know if it doesn't work.

blue_muppet
March 2nd, 2006, 09:30 AM
mate, first of all thanks for your response!

but no love! i still receive nothing as a result of this one :(

man, this is starting to really get to me. as far as i can see, all the different types of code i have used all have the same basic principle, all work with no errors, and yet i still dont get any email sent to me when i test them... :*(

this is what i was trying before your example:



<?php

$vars = array("name", "email", "message", "recip", "toEmail");

foreach($vars as $var)
if(isset($_POST[$var]))
$$var = $_POST[$var];
else
$$var = '';


$recip = $toEmail;



$message = str_replace("\r", "\n", $message);

$sender = $_SERVER[REMOTE_ADDR];

$mailbody = "testing";


mail($recip, "test", $mailbody, "From: test");

?>


and submit button had:



on (press) {
mylv = new LoadVars();
myreply = new LoadVars();
mylv.email = email;
mylv.name = name;
mylv.message = message;
mylv.recip = recip;
mylv.toEmail = toEmail;
}

on (release) {gotoAndPlay("sent");

}


email, name, and message were all specified in dynamic text boxes outside of the stage view...

Boerboel649
March 2nd, 2006, 12:28 PM
Hey,
I went to test it out myself and got it to work. I think I left out somethin' though.

Here's what I did and it works wonderfully.

Create input boxes one for name, one for email and the other for the recipients email address. Give name the instance name "Sname" (without the quotes) give the email box the instance name "Semail" (again without the quotes) and the recipient box the name "Srecipient" (again without the quotes). Click on the name input box and give it the Var "name" (without the quotes) click on the email input box and give it the Var "email" (without the quotes) click on the recipient input box and give it the Var "recipient" (without the quotes) And in the submit button put this code

on (release) {
if (Sname.text != "" && Semail.text != "" && Srecipient.text != "") {
loadVariablesNum ("emailtest.php", 0, "POST");
gotoAndStop (2);
} else {
stop();
Serror._visible = true
}
}
Now in the php file emailtest.php put the follwing php.


<?

$to = $recipient;
$subject = "This is a cool site!";
$msg = "$name has sent you this 'cause he thinks it's a cool site that you should check out.";
mail($to, $subject, $msg, "From: yoursite@yourdomain.com\nReply-To: $email\n");

?>

Be sure to save it as emailtest.php and to save it in the same folder as the .swf is in. Let me know if it doesn't work. Make sure you follow the directions exactly, then once you get it working, you can modify it for your needs. It worked for me. If you still can't get it working, I can send you the source files (the .swf and the php file.)