When I send the email, the email is sent with only attachment and the message part does not appear. The preview say no text body. What went wrong? The code is provided below:
<?php
include 'header.php';
if(isset($_POST['bookingsubmit']))
{
//print_r($_POST);
$to = "dungeonr977@gmail.com";
$from = $_POST['email'];
$first_name = $_POST['fName'];
$last_name = $_POST['lName'];
$mobile= $_POST['mobile'];
$airline= $_POST['airline'];
$subject = "Flight Change Request";
$file_name = $_FILES['file']['name'];
$temp_name = $_FILES['file']['tmp_name'];
$file_type = $_FILES['file']['type'];
$base = basename($file_name);
$extension = substr($base, strrpos($base, ".")-1);
$file = $temp_name;
$content = chunk_split(base64_encode(file_get_contents($file)));
$uid = md5(uniqid(time())); //unique identifier
$message = "Mr/Mrs/Ms ".$first_name." ".$last_name." wrote the following:"."
".$_POST['message'];
$headers = 'MIME-Version: 1.0';
$headers .= "From:" . $from;
$headers .= "X-Mailer: PHP/".phpversion()."
";
//$headers .= "--".$uid."
";
$headers .= "Content-Type: ".$file_type."; name=\"".$file_name."\"
";
$headers .= "Content-Transfer-Encoding: base64
";
$headers .= "Content-Disposition: attachment; filename=\"".$file_name."\"
";
$headers .= $content;
//$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
}
?>