sql - How to fix this php file for sending email

i have created this php form for enquiry purpose but when i clicked on the submit button it's not working. can you tell me what have i done wrong in this code.

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <input type ="text" name="subject" placeholder="subject">
    <input type ="email" name="email" placeholder="email">
    <textarea rows="5" name="message" cols="30"></textarea>
    <input  class="btn" type="submit" name="submit" value="Submit">
</form>


   <?php
if(isset($_POST['submit'])){
    $to = "rizwandesigns19@gmail.com";
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $from = $_POST['email'];
    
    $headers = "From : $from";

    mail($to, $subject, $message, $headers);
}

echo "Mail Sent";
?>

or can you give me valid php script for this purpose.

Answer

Solution:

To get through google's and other's spam filters you need an address which the mail is sent from. For this you could create a new Gmail-address and use the phpmailer-library.

Source