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

PHP Form Help please...????

P: 1
Hi Guys i could do with some help please, i have the following script but for the life of me i can see to get the form to forward to my email address of *** please help?!?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $owner_email = $_POST["owner_email"];
  3.     $headers = 'From:' . $_POST["email"];
  4.     $subject = 'A message from your site visitor ' . $_POST["name"];
  5.     $messageBody = "";
  6.  
  7.     $messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
  8.     $messageBody .= '<br>' . "\n";
  9.     $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
  10.     $messageBody .= '<br>' . "\n";
  11.     if($_POST['state']!='nope'){        
  12.         $messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";
  13.         $messageBody .= '<br>' . "\n";
  14.     }
  15.     if($_POST['phone']!='nope'){        
  16.         $messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
  17.         $messageBody .= '<br>' . "\n";
  18.     }    
  19.     if($_POST['fax']!='nope'){        
  20.         $messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";
  21.         $messageBody .= '<br>' . "\n";
  22.     }
  23.     $messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
  24.  
  25.     if($_POST["stripHTML"] == 'true'){
  26.         $messageBody = strip_tags($messageBody);
  27.     }
  28.  
  29.     try{
  30.         if(!mail($owner_email, $subject, $messageBody, $headers)){
  31.             throw new Exception('mail failed');
  32.         }else{
  33.             echo 'mail sent';
  34.         }
  35.     }catch(Exception $e){
  36.         echo $e->getMessage() ."\n";
  37.     }
  38. ?>


many thanks!!!!!!!!!!!!
Feb 6 '12 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
have you verified that all input is passed correctly (and the mail() function didn't fail)?

note: mail() only forwards the mail to the sendmail binary (or equivalent). it gives no guarantee that the mail is delivered at all.
Feb 7 '12 #2

Post your reply

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