I am a beginner to PHP,, I just wanted to create a basic registration form to fill in the details and send mail. I have this on a remote server. I am not able to send email. Can someone please help me resolve the issue .
if($conn->query($sql) === TRUE){
    $message =
   'ID: 201701'.$conn->insert_id. '
    Prefix: ' . $prefix . '
    Name: ' . $name . '
    Contact Number: ' . $contactNo . '
    Address: ' . $Address . '
    Email: ' . $email . '
    Job Title: ' . $JobTitle . '
    Organization: ' . $Organization . '
    City: ' . $City . '
    State: ' . $State . '
    Pin Code: ' . $Pincode;     
    mail('info@xyz.com', 'Registration for xyz',$message, $name."<".$email.">"); 
It sends email to info@xyz.com, but it does not send an email to the one given below.
       $email = "yyyy@gmail.com";
       $to = $email;
        $subject = "Confirmation mail";
        $message = "Hello $prefix $name     
        ID: 201701$conn->insert_id
        Prefix:  $prefix 
        Name:  $name 
        Contact Number:  $contactNo 
        Address:  $Address 
        Email:  $email 
        Job Title:  $JobTitle 
        Organization:  $Organization 
        City:  $City 
        State:  $State 
        Pin Code:  $Pincode";
        $from = "xxx@xxx.com" ;
        $headers = "From: XXX 2016<xxx@xxxx.com>";
        $mail = mail($to,$subject,$message,$headers);
    } 
     else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
    if($mail)
    {
        echo '<p style="font-size:22px; color:green"><b>Thank You !<br/><br/>You are now Registered.</b></p>';
    }        
    else
    {
    echo '<span style="color:red">Your registration was not successful. Please try again later or send a mail to xxx@xxxx.com</span>';
    }
ps. Dont consider the number of xxx or yyy in the email id, It is just some random mail.
 
    