0

Please help me. I am new in PHP. My mail function is not working even on live server. I don't know whats wrong with my code.

<div class="contact-form">
            <h4>Get in Touch</h4>
            <form name="contactform" method="post" action="send_form_email.php">
                <div class="col-md-6 form-left">
                    <input type="text" placeholder="Name" name="name" required="">
                </div>
                <div class="col-md-6 form-right">
                    <input class="email" type="email" name="email" placeholder="Email" required="">
                </div>
                <div class="clearfix"> </div>
                    <input class="" type="text" placeholder="Phone" name="phone" required="">
                    <textarea class="" placeholder="Message" name="message" required=""></textarea>
                    <input type="submit" value="SUBMIT" >
            </form>
        </div>

And here is my mail function file. name send_form_email.php.

    <?php 
if(isset($_POST['submit'])){
    $to = "ali.gohar@gmail.com"; // this is your Email address
    $from = $_POST['email']; // this is the sender's Email address
    $name = $_POST['first_name'];
    $phone = $_POST['phone'];
    $message = $name . " " . $email . " " . $phone . "wrote the following:" . "\n\n" . $_POST['message'];


    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers);

    echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";

    }
?>
ali gohar
  • 1
  • 2

0 Answers0