Email is not sent

Hi.
Iam trying to sent this form values to my email
Its not working
Can anyone help to solve this…

This is my form


<form method="POST" action="sendemail.php">
<table width="450px">
<tr>
 <td valign="top">
  <label for="name">Name </label>
 </td>
 <td valign="top">
  <input  type="text" name="name" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="organisation">Organisation </label>
 </td>
 <td valign="top">
  <input  type="text" name="organisation" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="contact">Contact no </label>
 </td>
 <td valign="top">
  <input  type="text" name="contact" maxlength="80" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="remarks">Remarks</label>
 </td>
 <td valign="top">
 <textarea  name="remarks" maxlength="50" ></textarea>

 </td>
</tr>
<tr>
 <td valign="top">
  <label for="designation">Designation </label>
 </td>
 <td valign="top">
  <input  type="text" name="designation" maxlength="50" size="50">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="email">E-mail </label>
 </td>
 <td valign="top">
 <input  type="text" name="email" maxlength="50" size="40">
   </td>
</tr>
<tr>
 <td colspan="2" style="text-align:center">
  <input type="submit" value="Submit"> <input type="reset" value="Reset">
 </td>
</tr>
</table>

 </form>


this is sendemail.php


<?php
session_start();
if(isset($_POST['email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "-----------------l@gmail.com";
    $email_subject = "Contact Details";


    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }

    // validation expected data exists
    if(!isset($_POST['name']) ||
        !isset($_POST['organisation']) ||
        !isset($_POST['email']) ||
		!isset($_POST['contact']) ||
        !isset($_POST['designation']) ||
        !isset($_POST['remarks'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');
    }

    $name = $_POST['name'];
    $organisation = $_POST['organisation'];
    $email = $_POST['email'];
    $contact = $_POST['contact'];
	$designation = $_POST['designation'];
    $remarks = $_POST['remarks'];

    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$name)) {
    $error_message .= 'Name you entered does not appear to be valid.<br />';
  }
    if(strlen($remarks) < 2) {
    $error_message .= 'The Remarks you entered do not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\
\
";

    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }

    $email_message .= "Name: ".clean_string($name)."\
";
    $email_message .= "Organisation: ".clean_string($organisation)."\
";
	$email_message .= "Contact No: ".clean_string($contact)."\
";
    $email_message .= "Email: ".clean_string($email)."\
";
    $email_message .= "Remarks: ".clean_string($remarks)."\
";
    $email_message .= "Designation: ".clean_string($designation)."\
";


$headers = 'From: '.$email."\\r\
".
'Reply-To: '.$email."\\r\
" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
}?>
<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.




unless you are specifing your own function called ‘died()’ somewhere I can see, you need to change all 2 instances of that to die().

change


'X-Mailer: PHP/' . phpversion(); 

to


'X-Mailer: PHP/' . phpversion() . "\\r\
"; 

Hi…

Thank for your reply…

But still the values of the form is not sent to the mail id

OK, you said it wasnt working, I assumed that you were not getting the email !! Give me 5

your script works fine, ive tried it on my server here and all is OK

Should i change the function died() to function die()??

Its not actually stopping the script from working here (surprisingly) but Id change it for the sake of correctness.

iam trying to run in wamp server
should i setup any mail server for testing the script \locally??

your server will need to have an SMTP server configured and running to test this script yes, PHP doesnt send the mail, it only passes it to the local SMTP server.

On this thread I suggested to use CRLF:

Even though it did not solve that problem but maybe should try it here and see if it will work.

This type of errors is due to send a line more than 1000 characters long:
http://www.tech-pro.net/tcpip4.html
http://mgrand.home.mindspring.com/mime.html

Tom, its being run on Wamp … hence no mail

Thanks. Next time I post, I better make sure to read every posts. :blush: