By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,724 Members | 1,868 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,724 IT Pros & Developers. It's quick & easy.

PHP Problems - Sending Mail from Form

P: 2
Hi - Not sure if this is exactly the right forum to enter this is - but need to start somewhere as I don't know where it's not working.

I have a contact form on a flash website, when the submit button is pressed, another window opens to say the mail has been sent - when it hasn't (Ihave changed this to read there was a problem). I can't see anything in the logfiles to say what hasn't worked - but it's driving me crazy. The file called upon is contact.php which is why I'm here;

Expand|Select|Wrap|Line Numbers
  1. <?
  2. Error_Reporting(E_ALL & ~E_NOTICE);
  3.  
  4.  while ($request = current($_REQUEST)) {
  5.      if (key($_REQUEST)!='recipient') {
  6.         $pre_array=split ("&777&",  $request);
  7.         $post_vars[key($_REQUEST)][0]=$pre_array[0];
  8.         $post_vars[key($_REQUEST)][1]=$pre_array[1];
  9.     }
  10.     next($_REQUEST);
  11. }
  12.  
  13.  
  14.  
  15. reset($post_vars);
  16.  
  17. $sendTo ="Web@email.co.uk" ;
  18. $subject="From ".$post_vars['your_name'][0] ;
  19. $headers="From: ".$post_vars['your_email'][0] ."\n";
  20. $headers.='Content-type: text/html; charset=iso-8859-1';
  21. $message='';
  22.   while ($mess = current($post_vars)) {
  23.       if ((key($post_vars)!="i") && (key($post_vars)!="your_email") && (key($post_vars)!="your_name")) {
  24.  
  25.          $message.="<strong>".$mess[1]."</strong>&nbsp;&nbsp;&nbsp;".$mess[0]."<br>";
  26.     }
  27.     next($post_vars);
  28.  }
  29.  
  30. mail($sendTo, $subject, $message. $headers);
  31. echo ("There was a problem sending the email - sorry for the inconvenience");
  32.  
  33. ?>
  34.  
Expand|Select|Wrap|Line Numbers
  1. <script>
  2.     resizeTo(450, 300);
  3. </script>
  4.  
Can anyone help? Do you need anymore information?

Thanks
TB
Sep 28 '08 #1
Share this Question
Share on Google+
3 Replies


P: 3
Not too sure, but your code looks wrong, the error message should fire all the time successful or otherwise. In any case, the built-in mail function is not really a very good sender.

<removed advertising>
Oct 1 '08 #2

100+
P: 190
Not sure..may u try with
[code=php]
if(! mail($sendTo, $subject, $message. $headers))
{
echo ("There was a problem sending the email - sorry for the inconvenience");
}
[/php]
Oct 1 '08 #3

P: 2
The error message does come up all the time- I changed the text as it used to say "thanks - your mail has been sent succesfully" - when it hadn't.

The problem is the message does not send or I don't get it - and I've got no idea how to make it work - happy to have it saying thanks - your mail has been sent succesfully" when I know it's going to get to me.
Oct 3 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.