|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have a web page running.
One thing is not working on it. It is not sending the emails from the web, I have the following entry in the *.php file - what is wrong with it? mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders); Please ee below for the full form. Thanks <? // THIS IS THE BEGIINNING OF THE PHP CODE $name = $_POST['name']; $country = $_POST['country']; $phone = $_POST['phone']; $email = $_POST['email']; $comments = $_POST['comments']; $error_msg=""; $msg=""; if(!$name){ $error_msg .= "Your name \n"; } if($name){ $msg .= "Name: \t $name \n"; } if(!$country){ $error_msg .= "Your country \n"; } if($country){ $msg .= "Country: \t $country \n"; } if(!$phone){ $error_msg .= "Your phone \n"; } if($phone){ $msg .= "Phone: \t $phone \n"; } if(!$email){ $error_msg .= "Your email \n"; } if($email){ if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ echo 'That is not a valid email address. Please<a href="javascript:history.back()"> return </a> to the previous page and try again.'; exit; } $msg .= "Email: \t $email \n"; } if(!trim($comments)){ $error_msg .= "Your comments \n"; } if($comments){ $msg .= "Comments: \t $comments \n"; } $sender_email=""; if(!isset($name)){ if($name == ""){ $sender_name="noisevx.com Customer"; } }else{ $sender_name=$name; } if(!isset($email)){ if($email == ""){ $sender_email="customer@noisevx.com"; } }else{ $sender_email=$email; } if($error_msg != ""){ echo"You didn't fill in these required fields:<br>" . nl2br($error_msg) .'<br>Please <a href="javascript:history.back()"> return </a> to the' ." previous page and try again."; exit;} $mailheaders = "MIME-Version: 1.0\r\n"; $mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $mailheaders .= "From: $sender_name <$sender_email>\r\n"; $mailheaders .= "Reply-To: $sender_email <$sender_email>\r\n"; mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders); header("Location: http://www.xxx.com/index.html"); /* Redirect browser */ //THIS IS THE END OF THE PHP CODE ?> |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
2007 wrote:
> I have a web page running. > One thing is not working on it. > It is not sending the emails from the web, > > I have the following entry in the *.php file - what is wrong with it? > > mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders); > > Please ee below for the full form. > > Thanks > > <? > // THIS IS THE BEGIINNING OF THE PHP CODE > > $name = $_POST['name']; > $country = $_POST['country']; > $phone = $_POST['phone']; > $email = $_POST['email']; > $comments = $_POST['comments']; > $error_msg=""; > $msg=""; > > if(!$name){ > $error_msg .= "Your name \n"; > } > if($name){ > $msg .= "Name: \t $name \n"; > } > > if(!$country){ > $error_msg .= "Your country \n"; > } > if($country){ > $msg .= "Country: \t $country \n"; > } > > if(!$phone){ > $error_msg .= "Your phone \n"; > } > if($phone){ > $msg .= "Phone: \t $phone \n"; > } > > if(!$email){ > $error_msg .= "Your email \n"; > } > if($email){ > if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ > echo 'That is not a valid email address. Please<a > href="javascript:history.back()"> return </a> to the previous page > and try again.'; > exit; > } > $msg .= "Email: \t $email \n"; > } > > if(!trim($comments)){ > $error_msg .= "Your comments \n"; > } > if($comments){ > $msg .= "Comments: \t $comments \n"; > } > $sender_email=""; > > if(!isset($name)){ > if($name == ""){ > $sender_name="noisevx.com Customer"; > } > }else{ > $sender_name=$name; > } > if(!isset($email)){ > if($email == ""){ > $sender_email="customer@noisevx.com"; > } > }else{ > $sender_email=$email; > } > if($error_msg != ""){ > echo"You didn't fill in these required fields:<br>" > . nl2br($error_msg) .'<br>Please <a > href="javascript:history.back()"> return </a> to the' > ." previous page and try again."; > exit;} > $mailheaders = "MIME-Version: 1.0\r\n"; > $mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n"; > $mailheaders .= "From: $sender_name <$sender_email>\r\n"; > $mailheaders .= "Reply-To: $sender_email <$sender_email>\r\n"; > mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders); > header("Location: http://www.xxx.com/index.html"); /* Redirect browser > */ > //THIS IS THE END OF THE PHP CODE ?> You might try outputting your variables first to make sure they are assigned what you expect them to be assigned. That is usually the first place to look. Something as simple as: $msg = stripslashes($msg); echo "Message:<br>".$msg."<br>"; echo "Mail Headers:<br>".$mailheaders; Always check your inputs. Then check to make sure the mail() function is working. $result = mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders); if(!$result) { echo "Mail function not sending mail.<br>"; } This will not tell you if the mail is deliverable, but will tell you if the function sent the data to the server. You way also want to ensure all your opening and closing tags are: <?php {code} ?> Using the short tag <? can give you many headaches down the road. Hopefully that will you narrow down the problem. Scotty |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Scott wrote:
> 2007 wrote: >> I have a web page running. >> One thing is not working on it. >> It is not sending the emails from the web, >> >> I have the following entry in the *.php file - what is wrong with it? >> >> mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders); >> >> Please ee below for the full form. >> >> Thanks >> >> <? >> // THIS IS THE BEGIINNING OF THE PHP CODE >> >> $name = $_POST['name']; >> $country = $_POST['country']; >> $phone = $_POST['phone']; >> $email = $_POST['email']; >> $comments = $_POST['comments']; >> $error_msg=""; >> $msg=""; >> >> if(!$name){ >> $error_msg .= "Your name \n"; >> } >> if($name){ >> $msg .= "Name: \t $name \n"; >> } >> >> if(!$country){ >> $error_msg .= "Your country \n"; >> } >> if($country){ >> $msg .= "Country: \t $country \n"; >> } >> >> if(!$phone){ >> $error_msg .= "Your phone \n"; >> } >> if($phone){ >> $msg .= "Phone: \t $phone \n"; >> } >> >> if(!$email){ >> $error_msg .= "Your email \n"; >> } >> if($email){ >> if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ >> echo 'That is not a valid email address. Please<a >> href="javascript:history.back()"> return </a> to the previous page >> and try again.'; >> exit; >> } >> $msg .= "Email: \t $email \n"; >> } >> >> if(!trim($comments)){ >> $error_msg .= "Your comments \n"; >> } >> if($comments){ >> $msg .= "Comments: \t $comments \n"; >> } >> $sender_email=""; >> >> if(!isset($name)){ >> if($name == ""){ >> $sender_name="noisevx.com Customer"; >> } >> }else{ >> $sender_name=$name; >> } >> if(!isset($email)){ >> if($email == ""){ >> $sender_email="customer@noisevx.com"; >> } >> }else{ >> $sender_email=$email; >> } >> if($error_msg != ""){ >> echo"You didn't fill in these required fields:<br>" >> . nl2br($error_msg) .'<br>Please <a >> href="javascript:history.back()"> return </a> to the' >> ." previous page and try again."; >> exit;} >> $mailheaders = "MIME-Version: 1.0\r\n"; >> $mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n"; >> $mailheaders .= "From: $sender_name <$sender_email>\r\n"; >> $mailheaders .= "Reply-To: $sender_email <$sender_email>\r\n"; >> mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders); >> header("Location: http://www.xxx.com/index.html"); /* Redirect browser >> */ >> //THIS IS THE END OF THE PHP CODE ?> > You might try outputting your variables first to make sure they are > assigned what you expect them to be assigned. That is usually the first > place to look. > > Something as simple as: > > $msg = stripslashes($msg); > echo "Message:<br>".$msg."<br>"; > echo "Mail Headers:<br>".$mailheaders; > > Always check your inputs. > > Then check to make sure the mail() function is working. > > $result = mail("abc7@gmail.com ","Contact",stripslashes($msg), > $mailheaders); > if(!$result) { > echo "Mail function not sending mail.<br>"; > } > > This will not tell you if the mail is deliverable, but will tell you if > the function sent the data to the server. > > You way also want to ensure all your opening and closing tags are: > > <?php > {code} > ?> > > Using the short tag <? can give you many headaches down the road. > > Hopefully that will you narrow down the problem. > > Scotty Also, read about the 'else' keyword .-thib´ |
|
![]() |
| Outils de la discussion | |
|
|