Here is my complete code of php mail. My code is working fine but I want to include file as attachement. Where should i add which code to send mail with attachement. No new code is needed. I want to use the same code. can any one find it out and fix it.
<?php
if(isset($_POST["submit"])){
$file_name = $_FILES['fileToUpload']['name'];
$file_name1 = rand().$file_name;
$file_tmp = $_FILES['fileToUpload']['tmp_name'];
move_uploaded_file($file_tmp,"cv/".$file_name1);
$conn = mysqli_connect("localhost", "", "", "");
if($conn === false){
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
$CV = $_REQUEST['fileToUpload'];
$Name = $_REQUEST['name'];
$Email = $_REQUEST['email'];
$Mobile = $_REQUEST['mobile'];
$CGPA = $_REQUEST['cgpa'];
$RegNo = $_REQUEST['regno'];
$Position = $_REQUEST['position'];
$Why = $_REQUEST['why'];
$sql = "INSERT INTO `ExecutiveBody`(`ID`, `CV`, `Name`, `Email`, `Mobile`, `CGPA`, `RegNo`, `Position`, `Why`) VALUES ('','$file_name1','$Name','$Email','$Mobile','$CGPA','$RegNo','$Position','$Why')";
if(mysqli_query($conn, $sql)){
echo "<script>alert('Thanks For Your Interest. Check Your Email For Confirmation.');</script>";
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($conn);
}
$to = "mail@hotmail.com"; // this is your Email address
$from = $_REQUEST['email']; // this is the sender's Email address
$name = $_REQUEST['name'];
$mobile = $_REQUEST['mobile'];
$cgpa = $_REQUEST['cgpa'];
$regno = $_REQUEST['regno'];
$position = $_REQUEST['position'];
$why = $_REQUEST['why'];
$cv = $_REQUEST['cv'];
$subject = "Executive Body | Application";
$subject2 = "Copy Of Your Executive Body Application Submission";
$message = "<b>Name: </b>" . $name . "<br><br>" . "<b>Email: </b>" . $from . "<br><br>" ."<b>Mobile: </b>" . $mobile . "<br><br>" . "<b>CGPA: </b>" . $cgpa . "<br><br>" . "<b>Reg No: </b>" . $regno . "<br><br>" . "<b>Position: </b>" . $position . "<br><br>" . "<b>Why You Want To Be Part Of Society?: </b><br><br>" . $why;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "From:" . $from;
mail($to,$subject,$message,$headers);
// Close connection
mysqli_close($conn);
}
?>