...

View Full Version : Neither GET nor POST will work for email



SteveH
12-31-2007, 08:07 PM
Hello

I am trying to send an email to my own inbox from a contact form here:

http://stevehigham59.7host.com/myFlash/graphic9.html

The email refuses to be sent and I have received nothing in my email box.

I have tried the PHP script using GET as follows:

<?php

//create short variable names
$name=$_GET['name'];
$email=$_GET['email'];
$business=$_GET['business'];
$country=$_GET['country'];
$message=$_GET['message'];
$name=trim($name);
$email=trim($email);
$business=StripSlashes($business);
$country=StripSlashes($country);
$message=StripSlashes($message);

/*#########
modify the next line with your own email address
###########*/

$toaddress='myName@myInbox.com';


mail($toaddress,$business,$country,$message,"From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n");
//clear the variables
$name='';
$email='';
$business='';
$country='';
$message='';
exit;
?>

And I have tried it using POST:

<?php

//create short variable names
$name=$_POST['name'];
$email=$_POST['email'];
$business=$_POST['business'];
$country=$_POST['country'];
$message=$_POST['message'];
$name=trim($name);
$email=trim($email);
$business=StripSlashes($business);
$country=StripSlashes($country);
$message=StripSlashes($message);

/*#########
modify the next line with your own email address
###########*/

$toaddress='myName@myInbox.com';


mail($toaddress,$business,$country,$message,"From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n");
//clear the variables
$name='';
$email='';
$business='';
$country='';
$message='';
exit;
?>

But neither seems to work. Is it likely that the above scripts are incorrect, or is it likely that Flash cannot see my PHP file?

Many thanks.

Steve

fl00d
12-31-2007, 08:35 PM
For one, did you put in your own email?

$toaddress='myName@myInbox.com';

Also, try adding this with your variables. I think mail() can only take one variable for its message part.


$completeMessage = $business."\n".$country."\n".$message."";
$headers = "From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n";

Add that to the bottom of your variable list and then modify the mail() statement like so:

mail($toaddress,$completeMessage,$headers);

What does your form look like?

SteveH
01-03-2008, 01:41 AM
Hello fl00d

Thank you for your post.

This is the code I have now (which does not work):

<?php

//create short variable names
$name=$_POST['name'];
$email=$_POST['email'];
$business=$_POST['business'];
$country=$_POST['country'];
$message=$_POST['message'];
$name=trim($name);
$email=trim($email);
$business=StripSlashes($business);
$country=StripSlashes($country);
$message=StripSlashes($message);

/*#########
modify the next line with your own email address
###########*/

$toaddress='myEmail@yahoo.com';

mail($toaddress,$business,$country,$message,"From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n");
//clear the variables
$name='';
$email='';
$business='';
$country='';
$message='';
exit;

?>
The form I have looks like this:

http://stevehigham59.7host.com/myFlash/graphic9.html

Yes, I did put in my own email address and I DO receive a message, but in the from field I have: me@localhost.com and there is nothing about the user's email.

However, I get (in the message field of my own inbox) USA (where I have typed in USA in the country field), and I get the message I typed in in the message field.

It seems to be retrieving some data (but not the email address) and it is not formatted coherently.

Would you please indicate where/how I should make the amendments you suggest?

Thanks again for your help.

Best for 2008!

Steve

rfresh
01-03-2008, 03:15 AM
Where did you get those $business, $country arguments from? Those arguments are not right.

These are the arguments to use mail():

mail("$to", "$subject", "$body", "$from");

*That* works - give it a shot...

SteveH
01-03-2008, 11:04 PM
Hello rfresh

Thank you for your post.

I do receive an email when I send it to myself, but the email appears not to be sending after I press submit.

Should the code, then, look something like this:

<?php

//create short variable names
$name=$_POST['name'];
$email=$_POST['email'];
$business=$_POST['business'];
$country=$_POST['country'];
$message=$_POST['message'];
$name=trim($name);
$email=trim($email);
$business=StripSlashes($business);
$country=StripSlashes($country);
$message=StripSlashes($message);

/*#########
modify the next line with your own email address
###########*/

$toaddress='myEmail@yahoo.com';


mail("$toaddress","$business","$country","$message","From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n");
//clear the variables
$name='';
$email='';
$business='';
$country='';
$message='';
exit;

?>

Many thanks.

Steve

Spookster
01-03-2008, 11:51 PM
The previous posters have already pointed this out but you should review the parameters you are passing to the mail function Please review the mail function in the documentation http://us.php.net/function.mail

SteveH
01-04-2008, 03:08 PM
Hello Spookster

Many thanks for your message and link. I have downloaded it and it looks heavy, but I will try to pursue!

Thanks.

Steve



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum