• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 485
  • Last Modified:

NEW FORM SAYS SUCCESSFULLY SENT BUT NO EMAIL IN INBOX

I have a form in my flash file that i have uploaded to the server along with the php file. Now when i test it, it says the message was succesfully sent however i'm not actually receiving the email in my inbox
this is the  php script. could anyone tell where i'm going wrong as i really dont want another night without sleep.  code is as follows:-

<?

Error_Reporting(E_ALL & ~E_NOTICE);
$subject="from ".$_REQUEST['Your_Name:'] ;
$headers= "From: ".$_REQUEST['Your_Email:'] ."\n";
 $headers.='Content-type: text/html; charset=iso-8859-1';
 $message='';
  while ($field = current($_REQUEST)) {
        if ((key($_REQUEST)!="Your_Name:") && (key($_REQUEST)!="Your_Email:") && (key($_REQUEST)!="Message:") && (key($_REQUEST)!="i")) {
             $message.="<strong>".key($_REQUEST)."</strong>&nbsp;&nbsp;&nbsp;".$field."<br>";
      }
      next($_REQUEST);
 }
$message.="<br>".$_REQUEST['Message:'];
mail($_REQUEST['superdaveyk@hotmail.co.uk'], $subject,  "
<html>
<head>
 <title>Contact letter</title>
</head>
<body>
<br>
  ".$message."
</body>
</html>" , $headers);
echo ("Your message was successfully sent!");

?>
<script>
      resizeTo(300, 300);

</script>
0
designbyknight
Asked:
designbyknight
  • 8
  • 8
  • 4
11 Solutions
 
chilternPCCommented:
you don't test for the sent being successful.
also if you are using PHP5 you may be a extra parameter  ("-f")  in the mail  function... see the attached code snippet.
at least test for the sent.
$sent = mail($email_to, $email_subject, $message, $headers, '-f' .$email_from);
 
	if ($sent)
		{
			/*If sent direct customers to thankyou page */
			header( "Location: http://www.kpequestrian.com/testthanks.htm" ); 
		} else {
			/* If there is an error display an error message */
			echo 'There has been an error sending your comments. Please try later.'; 
		}
?>

Open in new window

0
 
designbyknightAuthor Commented:
Hi chilternpc thanks for the reply
  I'm quite new to this game so i don't really understand your reply ...... how do i test for the sent ?
kindest regards
 
0
 
nanharbisonCommented:
You are just calling the mail function, which I have copied below, where chilternPC says to put it in an if statement, which will be in my next comment....

mail($_REQUEST['superdaveyk@hotmail.co.uk'], $subject,  "
<html>
<head>
 <title>Contact letter</title>
</head>
<body>
<br>
  ".$message."
</body>
</html>" , $headers);

Open in new window

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
nanharbisonCommented:
Here is your mail function in an if statement. A variable called $sent is being assigned to your mail function, which will be given the value of TRUE if the mail gets sent, and so the if statement  says:
 if ($sent)

which means if $sent is TRUE< then take the user to a page where they are thanked

$sent = mail($_REQUEST['superdaveyk@hotmail.co.uk'], $subject,  "
<html>
<head>
 <title>Contact letter</title>
</head>
<body>
<br>
  ".$message."
</body>
</html>" , $headers);
        if ($sent)
                {
                        /*If sent direct customers to thankyou page */
                        header( "Location: http://www.kpequestrian.com/testthanks.htm" ); 
                } else {
                        /* If there is an error display an error message */
                        echo 'There has been an error sending your comments. Please try later.'; 
                }

Open in new window

0
 
chilternPCCommented:
ok,
replace the line:
echo ("Your message was successfully sent!");
with

$sent = mail($email_to, $email_subject, $message, $headers, '-f' .$email_from);
if ($sent)
{echo ("Your message was successfully sent!");
} else {
echo 'There has been an error sending your comments. Please try later.';
}


0
 
chilternPCCommented:
sorry forgot to say replace the
mail($email_to, $email_subject, $message, $headers, '-f' .$email_from);
with your mail line

please not the "-f"
it will depend on what PHP version you are using.
0
 
designbyknightAuthor Commented:
thankyou for your comments both, am just checking my emails at work at the moment, so i will check these suggestions as soon as i get back home. I think i understand what you are getting at though.
Please excuse my ignorance for not knowing much about php,  but what i think you are trying to say is that in my php code, it doesn't actually check the email has really been sent it, merely opens the successfully sent as soon as something reaches the php code from the flash file.

   Please put me right if i'm wrong and like i say i will try this code alteration as soon as i get home
                a thousand thankyou's
                               Dave
0
 
nanharbisonCommented:
You are correct, you have code that the email was sent after using the PHP email function, without actually checking that it was sent.
0
 
designbyknightAuthor Commented:
Okay here is the new code ... did i get it rigth ... now when i fill out the form and clcik send it says internal server error and also mentions programming error.  here is the code :-

<?

Error_Reporting(E_ALL & ~E_NOTICE);
$subject="from ".$_REQUEST['Your_Name:'] ;
$headers= "From: ".$_REQUEST['Your_Email:'] ."\n";
 $headers.='Content-type: text/html; charset=iso-8859-1';
 $message='';
  while ($field = current($_REQUEST)) {
        if ((key($_REQUEST)!="Your_Name:") && (key($_REQUEST)!="Your_Email:") && (key($_REQUEST)!="Message:") && (key($_REQUEST)!="i")) {
             $message.="<strong>".key($_REQUEST)."</strong>&nbsp;&nbsp;&nbsp;".$field."<br>";
      }
      next($_REQUEST);
 }
$message.="<br>".$_REQUEST['Message:'];
<html>
<head>
 <title>Contact letter</title>
</head>
<body>
<br>
  ".$message."
</body>
</html>" , $headers);
$sent = mail($_REQUEST['superdaveyk@hotmail.co.uk'], $subject,  "
if ($sent)
{echo ("Your message was successfully sent!");
} else {
echo 'There has been an error sending your comments. Please try later.';
}


?>
<script>
      resizeTo(300, 300);

</script>
0
 
designbyknightAuthor Commented:
The error window i get up after i click send in my email form is the php file
  It gives the url of the php file in the address bar of the error message.
I guess that kind of means it's definately the php file. I have spoken to web server people and they say everything is set up on there side to deal with this php file. I guess it has got to be this php code.

Would it help if a post the actionscript on here from the flash file
   Thankyou
0
 
nanharbisonCommented:
There are some other things wrong here - I copied and pasted your mail function, which is missing some stuff, instead of this:

$sent = mail($_REQUEST['superdaveyk@hotmail.co.uk'], $subject,  "

use this:
$sent = mail($_REQUEST['superdaveyk@hotmail.co.uk'], $subject,  $message, $headers, $_REQUEST['Your_Email:']);

BUT FIRST, there are errors in the way you set up the variable you call $message. Try the code below for the message, I am not sure this is what you are trying to do though


$message.="<br>".$_REQUEST['Message:']. "
<html>
<head>
 <title>Contact letter</title>
</head>
<body>
<br>
</body>
</html>";

Open in new window

0
 
nanharbisonCommented:
oh wait, it should be $_REQUEST['Message'], NOT $_REQUEST['Message:'] (you have a colon in there after the word Message
0
 
designbyknightAuthor Commented:
so i need to copy and paste the first snippet of code in place of my mail line ... and then where $_REQUEST['Message:']
i need to replace with  $_REQUEST['Message']  ( i.e) get rid of the colon.
 I'm so excited that this might actually work , that would mean i get to go to sleep tonight .
   Thankyou
     Dave
0
 
designbyknightAuthor Commented:
also in the first code snippet      ['Your_Email:']);    do i need to replace your mail with my email address?
0
 
nanharbisonCommented:
it depends on who is getting your email and who is sending it? I was assuming the person filling out the form is who the mail is supposed to be from.
0
 
nanharbisonCommented:
['Your_Email:'] should not have a colon in it either, none of the REQUEST variables should have a colon.
0
 
designbyknightAuthor Commented:
I don't know if i'm doing something wrong here. I feel really paranoid so i'm gonna post the actionscript from flash and also the php script so you can see if the two marry up .

ACTIONSCRIPT FROM FLASH:
on (rollOver) {
      this.gotoAndPlay("s1");
}
on (releaseOutside, rollOut) {
      this.gotoAndPlay("s2");
}
on (release) {
      for (i=1; i<_parent.fields_descriptions.length; i++) {
            this[_parent.fields_descriptions[i][2]]=_parent[_parent.fields_descriptions[i][1]];
            _parent.reset_txt(_parent["t"+i], _parent.fields_descriptions[i][1], _parent.fields_descriptions[i][2]);
      }
      this.recipient=_parent.rec;
      i=undefined;
      getURL("contact."+_parent.serv, "_blank", "POST");
      
}


AND HERE IS THE SCRIPT FROM THE PHP FILE:-

<?

Error_Reporting(E_ALL & ~E_NOTICE);
$subject="from ".$_REQUEST['Your_Name:'] ;
$headers= "From: ".$_REQUEST['Your_Email:'] ."\n";
 $headers.='Content-type: text/html; charset=iso-8859-1';
 $message='';
  while ($field = current($_REQUEST)) {
        if ((key($_REQUEST)!="Your_Name:") && (key($_REQUEST)!="Your_Email:") && (key($_REQUEST)!="Message:") && (key($_REQUEST)!="i")) {
             $message.="<strong>".key($_REQUEST)."</strong>&nbsp;&nbsp;&nbsp;".$field."<br>";
      }
      next($_REQUEST);
 }
$message.="<br>".$_REQUEST['Message'];
<html>
<head>
 <title>Contact letter</title>
</head>
<body>
<br>
  ".$message."
</body>
</html>" , $headers);
$sent = mail($_REQUEST['superdaveyk@hotmail.co.uk'], $subject,  $message, $headers, $_REQUEST['Your_Email:']);
if ($sent)
{echo ("Your message was successfully sent!");
} else {
echo 'There has been an error sending your comments. Please try later.';
}


?>

Many thanks once again.
0
 
designbyknightAuthor Commented:
Oh dear
   I've just figured it out. Inside flash i found a script which i had not seen before which read:-

rec="Superdaveyk@hotmail.co.uk";
serv="php";

var fields_descriptions= Array ("",
                                                      Array("t1", "your_name", "Your Name:"),
                                                      Array("t2", "your_email", "Your Email:"),
                                                      Array("t3", "telephone", "Telephone:"),
                                                      Array("t4", "message", "Message:"),
                                                      Array("t5", "field_2", "E-mail:"),
                                                      Array("t6", "field_3", "Address:"),
                                                      Array("t7", "field_4", "fax:")
                                                );

function reset_txt(name,name2,value) {
            path=eval(_target);
            path[name2]="";
}
      


for (i=1; i<=fields_descriptions.length; i++) {
      reset_txt("t"+i, fields_descriptions[i][1], fields_descriptions[i][2]);
}

at the top of the script it states rec+ which i assume means recipient.
therefore in the php file where it says :-

mail($_REQUEST['recipient'], $subject,  "

it actually requests the recipient mail address from the flash file.

Not sure if this makes any sense but i must thankyou all for your time and effort on this. i feel ever so slightly silly but i suppose it's all a learning curve
 Once again many many thanks.
0
 
nanharbisonCommented:
So you are just going to close the question after we spent all this time helping you?  Did you know the experts on this site only get paid by the points you assign when your question is answered? I didn't know that when I first started using experts-exchange.
0
 
chilternPCCommented:
no worries - glad you got there in the end.
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 8
  • 8
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now