<?php 
if(isset($_POST['submit'])){
  
  
  
    $to = "rajivarchana0102@gmail.com"; // this is your Email address
    $from = "Contact-Enquiry"; // this is the sender's Email address
    
   
    $name = $_POST['name'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
 
    
    $message = $_POST['message'];
    
    
    $subject2 = "Copy of your form submission";
    $message = $name  . "\n\n Phone: ". $phone .  "\n\n Email: ". $email . "\n\n  Message: ". $message  ;
    $message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];

    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers);
    mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
    
    echo ".";?>
     <script >
 alert('Mail Sent. Thank you<?php " . $name . "?>, we will contact you shortly');
	 document.location.href = "contact.php"
   
    </script>
    <?php
    // You can also use header('Location: thank_you.php'); to redirect to another page.
    // You cannot use header and echo together. It's one or the other.
}
?>