-3

I have a contact form on my Contact page and it's a php page. I am gathering user's request and trying to mail it to me@mydomain.com. However, I tried all different ways but not able to send mail using php. I am very new to php and I am trying to learn the language. Here is the code sample.

This is my HTML

<h2>Your Details</h2></br>
<div class="form_row">
<input type="text" class="form_input" name="name" id="txtName" placeholder="Your Name"      />
</div>
<div class="form_row">
<input type="text" class="form_input" name="phone" id="txtPhone" placeholder="Phone Number" />
</div>
<div  class="form_row">
<input type="text" class="form_input" name="email" id="txtEmail" placeholder="Email" />
</div>
<div  class="form_row">
<textarea class="form_textarea" name="message" id="txtMessage" placeholder="Provide as much information you can regarding the project."></textarea>
<p><input type="submit" id="submit" class="button" value="Send"/></p>
                                                </div>

This is my php script

<?php
    if(isset($_POST['submit']))
    {           
        $to = "harish.upadhyayula@ritchsystems.com";
        $subject = 'Request for quote from - ritch systems website.';
        $from = 'Surekha';
        $phone = '410-555-4988';
        $message = 'Testing php mail by hard coding.';
        $headers =  "From: ".$from."\r\n" .  
                    "Phone: ".$phone;
        ini_set("sendmail_from", $from);
        if(mail( $to, $subject, $message, $headers ))
        {
        echo 'Mail Sent';
        }
        else {echo 'Something is wrong!';}
    }
?>
Daedalus
  • 7,586
  • 5
  • 36
  • 61

1 Answers1

3

try this type on server not on localhost(can't send mail on )

 $to = 'rsharma@gmail.com';
    $subject = 'Thanks for Registering on Dota Pub Stars!';
    $message = 'your msg';

        $headers = "MIME-Version: 1.0 \r\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1\n"; //sending html
        $headers .= "From: $from\r\n";

mail($to, $subject, $message, $headers);
Rakesh Sharma
  • 13,680
  • 5
  • 37
  • 44