Solved

NEW FORM SAYS SUCCESSFULLY SENT BUT NO EMAIL IN INBOX

Posted on 2008-10-01
20
465 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 28

Assisted Solution

by:chilternPC
chilternPC earned 220 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 280 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
 
LVL 17

Assisted Solution

by:nanharbison
nanharbison earned 280 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 28

Assisted Solution

by:chilternPC
chilternPC earned 220 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 28

Assisted Solution

by:chilternPC
chilternPC earned 220 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 280 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
Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

 
LVL 17

Assisted Solution

by:nanharbison
nanharbison earned 280 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 280 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 280 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 280 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 28

Expert Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Php pie charts 3 26
How to loop through records  using SELET COUNT 2 16
echo time from sql to input type="time" 9 20
Checking CSRF token within a function 36 14
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now