PDA

View Full Version : PHP Mail Form



wyclef
June 16th, 2003, 05:35 PM
Hi,

I'm trying to create a form field so the user can submit their email address but it doesn't seem to return the email address.

I have a file titled "mail.php"


<?php

mail("myEmail@domain.com", "Email Subject", $email);

?>


A button with this code attached...

on (release) {
loadVariablesNum("mail.php", "0", "POST");
email.text = "Thank You!";
}


And a textfield with the instance name "email"

lostinbeta
June 16th, 2003, 06:29 PM
Heres a bunch of threads on the subject of PHP E-mail forms both in and out of Flash...

http://www.kirupaforum.com/forums/search.php?s=&action=showresults&searchid=95094&sortby=lastpost&sortorder=descending


Ive never done a Flash/PHP Form so I won't be much help, but those threads have your answers.

ahmed
June 16th, 2003, 07:50 PM
try this
on (release) {
email = "Thank You!";
loadVariablesNum("mail.php", "0", "POST");
}

Jubba
June 17th, 2003, 02:04 AM
yeah, if you are receiving the e-mail, but it doesn't have any content, then do what ahmed said, and also put this line at the top of your PHP script...



$email = $_POST['email'];



also, make sure that you are giving the input box a variable name, not an instance name. I had a bit of trouble getting my variables to read from the instance name of an input box...

wyclef
August 3rd, 2003, 11:45 AM
This is what I have now,



<?PHP

$to = "myemail@email.com";

$msg = "$email\n\n";

mail($to, $msg, "For: Mailing List\nReply-To: $email\n");

?>


Everything works except the autoresponder for myemail@email.com doesn't get sent to the email address submitted. Is there a way to fix this with the code?

wyclef
August 4th, 2003, 05:35 PM
Any Ideas? :bounce:

Jubba
August 4th, 2003, 06:24 PM
your syntax is a little wrong.. it should be



mail(E-mail, SUBJECT, MESSAGE, HEADERS);



try this.... make a file called testMail.php and put this code in it...



<?

$to = "PUT YOUR ADDRESS HERE";
$subject = "Test E-mail";
$message = "This is a test e-mail";

$mail_test = mail($to, $subject, $message);

if($mail_test)
{
print "Mail sent successfully";
}
else
{
print "Error sending mail";
}

?>


Just put your e-mail address in where it says. If it still doesn't work then try this link : http://www.kirupa.com/web/testphp.htm

that will tell you if PHP is set up correctly on your server. If you get the correct screen then scroll down to where it says STMP and make sure it says localhost if not then your host probably has disabled it to prevent Spamming.



**Oh, yeah and you can't test this locally, it has to be tested on your server (that causes so much trouble....)

wyclef
August 4th, 2003, 06:33 PM
Hi, PHP has to be set up correctly on my server because the email data submitted is being sent, it's just that the email address submitted is not showing up as the "from" addres so the autoresponder doesn
t send a response to the submitted email. Here is my most updated code.



<?PHP

$to = "list@test.com";

$msg = "$email\n\n";

$subj = "Mailing List";

mail($to, $subj, $msg, "From: $email\r\nReply-To: $email\r\n");

?>

Jubba
August 4th, 2003, 06:34 PM
where are you defining the $email variable?

wyclef
August 4th, 2003, 06:38 PM
in the flash textfield

Jubba
August 4th, 2003, 06:44 PM
<?PHP

$email = $_POST['email'];

$to = "list@test.com";

$msg = "$email\n\n";

$subj = "Mailing List";

$header = "From: $email <$email>\r\n";

$header .= "Reply-To: $email\r\n";

mail($to, $subj, $msg, $header);

?>



try that... if that doesn't work then make sure you are using Ahmed's method of defining the Flash variable...

wyclef
August 4th, 2003, 08:46 PM
No go, the email goes through, everything is in check, but no autoresponse is sent. I DON'T GET IT!!! It even has the appropriate mail account. WHAT THE %&*$*$ IS GOING ON!!!!! ahhhhhhh

:b:

Jubba
August 4th, 2003, 08:47 PM
what do you mean autoresponse?

wyclef
August 4th, 2003, 08:49 PM
An autoresponder is an email that is set up to automatically be sent to any address it's receiving mail from.

Jubba
August 4th, 2003, 08:54 PM
ohhh... php doesn't do that. You have to use the e-mail client for something like that. That is something that you would have to set up in outlook...

Jubba
August 4th, 2003, 09:02 PM
and so you know this is incorrect:


"From: $email"

it has to be

"From: $email <$email>";

that is probably causing the problem. YOu need to have the e-mail address in there twice. Once as the name, and then again in the brackets so that the e-mail program will recognize it as an e-mail address...

code should look like this:



<?PHP

$to = "list@test.com";

$msg = "$email\n\n";

$subj = "Mailing List";

$header = "From: $email <$email>\r\n";

$header .= "Reply-To: $email\r\n";

mail($to, $subj, $msg, $header);

?>

wyclef
December 24th, 2003, 12:50 AM
Hi, this is PHP code I am using in conjunction with a flash form and i'm wondering how I can build in a bit of simple email address validation and possibly an autoresponder built into the PHP that gets sent to whatever address is submitted.




<?PHP
$email = $_POST['email'];
$to = "email@myemail.com";
$msg = "$email\n\n";
$subj = "Mailing List";
$header = "From: $email <$email>\r\n";
$header .= "Reply-To: $email\r\n";
mail($to, $subj, $msg, $header);
?>