Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

NEW FORM SAYS SUCCESSFULLY SENT BUT NO EMAIL IN INBOX

Posted on 2008-10-01
20
Medium Priority
?
478 Views
Last Modified: 2013-12-17
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
Comment
Question by:designbyknight
  • 8
  • 8
  • 4
20 Comments
 
LVL 29

Assisted Solution

by:chilternPC
chilternPC earned 880 total points
ID: 22619992
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
 

Author Comment

by:designbyknight
ID: 22620273
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
 
LVL 17

Assisted Solution

by:nanharbison
nanharbison earned 1120 total points
ID: 22620651
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Assisted Solution

by:nanharbison
nanharbison earned 1120 total points
ID: 22620670
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
 
LVL 29

Assisted Solution

by:chilternPC
chilternPC earned 880 total points
ID: 22621971
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
 
LVL 29

Assisted Solution

by:chilternPC
chilternPC earned 880 total points
ID: 22621978
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
 

Author Comment

by:designbyknight
ID: 22623251
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
 
LVL 17

Assisted Solution

by:nanharbison
nanharbison earned 1120 total points
ID: 22627052
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
 

Author Comment

by:designbyknight
ID: 22627216
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
 

Author Comment

by:designbyknight
ID: 22627376
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
 
LVL 17

Assisted Solution

by:nanharbison
nanharbison earned 1120 total points
ID: 22627660
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
 
LVL 17

Assisted Solution

by:nanharbison
nanharbison earned 1120 total points
ID: 22627673
oh wait, it should be $_REQUEST['Message'], NOT $_REQUEST['Message:'] (you have a colon in there after the word Message
0
 

Author Comment

by:designbyknight
ID: 22627757
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
 

Author Comment

by:designbyknight
ID: 22627772
also in the first code snippet      ['Your_Email:']);    do i need to replace your mail with my email address?
0
 
LVL 17

Assisted Solution

by:nanharbison
nanharbison earned 1120 total points
ID: 22627916
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
 
LVL 17

Assisted Solution

by:nanharbison
nanharbison earned 1120 total points
ID: 22627928
['Your_Email:'] should not have a colon in it either, none of the REQUEST variables should have a colon.
0
 

Author Comment

by:designbyknight
ID: 22627947
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
 

Accepted Solution

by:
designbyknight earned 0 total points
ID: 22628206
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
 
LVL 17

Expert Comment

by:nanharbison
ID: 22628335
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
 
LVL 29

Expert Comment

by:chilternPC
ID: 22629635
no worries - glad you got there in the end.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question