0
votes

I have a html contact form, which sends the info over email. It sends over and i receive the email, but only the attachment receive - I don't actually get the body of the email. Below is the PHP I am using, can anyone support? I am fairly new to PHP.

<?php

$filenameee =  $_FILES['file']['name'];
$fileName = $_FILES['file']['tmp_name']; 
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$usermessage = $_POST['message'];

$message ="Name = ". $name . "\r\n  Email = " . $email . "\r\n Message =" . $usermessage; 

$subject ="New contact enquiry!";
$fromname ="CoMPANY name";
$fromemail = '[email protected]';  

$mailto = '[email protected]';  




$content = file_get_contents($fileName);
$content = chunk_split(base64_encode($content));

$separator = md5(time());

$eol = "\r\n";

$headers = "From: ".$fromname." <".$fromemail.">" . $eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol;
$headers .= "Content-Transfer-Encoding: 7bit" . $eol;
$headers .= "This is a MIME encoded message." . $eol;

$body = "--" . $separator . $eol;
$body .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $eol;
$body .= "Content-Transfer-Encoding: 8bit" . $eol;
$body .= $message . $eol;

$body .= "--" . $separator . $eol;
$body .= "Content-Type: application/octet-stream; name=\"" . $filenameee . "\"" . $eol;
$body .= "Content-Transfer-Encoding: base64" . $eol;
$body .= "Content-Disposition: attachment; filename=\"".$filenameee."\"".$eol.$eol;
$body .= $content . $eol;
$body .= "--" . $separator . "--";