用PHP的html表单不发送电子邮件

I'm writing to create a contact form on my website and then get the information sent to my inbox, but it is not working. Please take a look at my code below (PHP is not my thing) and let me know where I've gone wrong.

here is my html form

<form action="" method="post">
      <div class="row">
        <div class="col-md-6">
           <input type="text" name="name" placeholder="Name"class="form-control"  required>
        </div>
        <div class="col-md-6">
            <input type="text" name="number" class="form-control" placeholder="Phone"required>
        </div>
      </div>
      <input type="email" class="form-control" placeholder="Email" name="email" required>
      <textarea name="message" class="form-control"style="resize:none;" placeholder="Message" rows="8" cols="30" required></textarea>
      <input type="submit" name="submit" value="contact us">
    </form>

This is my php code

<?php
$message ='';
if(isset($_POST['submit'])){
    $name =   $_POST['name'];

$email =   $_POST['email'];

$comments =  $_POST['message'];
$number = $_POST['number'];

$msg =  $name ."<br>".$email."<br>".$comments."<br>".$number;
$to = "karunagoyal7@gmail.com";
$subject = "Email from Contact Us from";

if(mail( $to, $subject, $msg)){
    $message = "<div class='alert alert-success'> your message has been send to saisoftlinktechnologies </div>";
}else{
    $message = "<div class='alert alert-primary'> your message has not been send to saisoftlinktechnologies </div>";
}
}

 ?>

Both html from and php script is in same file.After submitting the form it is not even displaying the message of success or failure.