I just tried to send email using html form and php, but not able to send email to the respective mail id provided in textbox as input.
I searched and got this example code, can anyone suggest me that where I made mistake.
html
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>Contact Form</title>
        <script  src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
        <link rel="stylesheet" type="text/css" href="./styles.css" />
        <script type="text/javascript">                                         
        /* <![CDATA[ */
            $(document).ready(function(){ // sends the data filled in the contact form to the php file and shows a message
                $("#contact-form").submit(function(){
                    var str = $(this).serialize();
                    $.ajax({
                       type: "POST",
                       url: "send.php",
                       data: str,
                       success: function(msg)
                       {
                            $("#formstatus").ajaxComplete(function(event, request, settings){
                                if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
                                    result = '<div class="formstatusok">Your message has been sent. Thank you!</div>';
                                    $("#fields").hide();
                                }
                                else{
                                    result = msg;
                                }
                                $(this).html(result);
                            });
                        }
                     });
                    return false;
                });
            });
        /* ]]> */   
        </script>  
    </head>
    <body>
        <div id="wrap">
            <h1>Drop me a Message!</h1>
            <div id='form_wrap'>
                <form id="contact-form" action="javascript:alert('success!');">
            <p id="formstatus"></p>
                    <p>Hello Joe,</p>
                    <label for="email">Your Message : </label>
                    <textarea  name="message" value="Your Message" id="message" ></textarea>
                    <p>Best,</p>    
                    <label for="name">Name: </label>
                    <input type="text" name="name" value="" id="name" />
                    <label for="email">Email: </label>
                    <input type="text" name="email" value="" id="email" />
                    <input type="submit" name ="submit" value="OK I want to send it now, thanks!" />
                </form>
            </div>
        </div>
    </body>
    </html>
send.php
    <?php
        define("WEBMASTER_EMAIL", 'myid@company.com');
        error_reporting (E_ALL ^ E_NOTICE);
        function ValidateEmail($email)
        {
            $regex = '/([a-z0-9_.-]+)'. # name
            '@'. # at
            '([a-z0-9.-]+){2,255}'. # domain & possibly subdomains
            '.'. # period
            '([a-z]+){2,10}/i'; # domain extension 
            if($email == '') 
                return false;
            else
                $eregi = preg_replace($regex, '', $email);
            return empty($eregi) ? true : false;
        }
    //////////////////////////////////////////////////////
        $post = (!empty($_POST)) ? true : false;
        if($post)
        {
            $name    = stripslashes($_POST['name']);
            $email   = trim($_POST['email']);
            $subject = stripslashes($_POST['subject']);
            $message = stripslashes($_POST['message']);
            $error = '';
            // Check name
            if(!$name || $name == "Name*")
                $error .= 'Please enter your name.<br />';
            // Check email
            if(!$email || $email == "Email*")
                $error .= 'Please enter an e-mail address.<br />';
            if($email && !ValidateEmail($email))
                $error .= 'Please enter a valid e-mail address.<br />';
            // Check message
            if(!$message)
                $error .= "Please enter your message. <br />";
            if(!$error)
            {
                $mail = mail(WEBMASTER_EMAIL, $subject, $message,
                     "From: ".$name." <".$email.">\r\n"
                    ."Reply-To: ".$email."\r\n"
                    ."X-Mailer: PHP/" . phpversion());
                if($mail)
                    echo 'OK';
            }
            else
                echo '<div class="formstatuserror">'.$error.'</div>';
        }
    ?>
Any ideas ?
 
     
     
     
     
    