when mail word file it is sent successfuly but when downloaded then it is corrupted. I don't know where is the mistake in the code. Plse check the code:-
email code is as follows
----------------
<?
function send_mail($myname, $myemail, $contactemail, $subject, $message, $attachtype, $type, $topic) {
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
//Finding whether the attachment type is Abstract or Paper
if ($type=="A")
$stype="Abstract";
elseif ($type=="P")
$stype="Paper";
//Checking the topic
switch ($topic)
{
case 1:
$stopic="Optoelectronics(including IR & PV)";
break;
case 2:
$stopic="VLSI & ULSI Technologies";
break;
case 3:
$stopic="Modelling and Simulation";
break;
case 4:
$stopic="Nano-Technology";
break;
case 5:
$stopic="High Frequency Devices";
break;
case 6:
$stopic="Growth & Characterization";
break;
case 7:
$stopic="Sensors & MEMS";
break;
case 8:
$stopic="Organic Semiconductors";
break;
case 9:
$stopic="Emerging Technoogies";
break;
}
//Adding the Name and the Email of the Sender in the email Message
$message = "Name:- " . $myname . "\n" . "Email:- " . $myemail . "\n" . "Attachment Type & Version:- " . $attachtype . "\n". "Type:- ". $stype . "\n". "Topic:- " . $stopic . "\n\n" . $message ;
//Giving a unique subject to all the mails.
$today = date("F j, Y, g:i:s a") ;
$subject = $subject ." :- " . $today;
$headers = "From:
secretary@iwpsd.net";
if (is_uploaded_file($fileatt)) {
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
// "Content-Type: application/msword \n" .
" boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\r\n\n" .
"--{$mime_boundary}\r\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\r\n" .
"Content-Transfer-Encoding: 8bit\r\n\n" .
$message . "\r\n\n";
$data = chunk_split(base64_encode($data)); //
// $data =convert_uuencode($some_string);
//$data = chunk_split($data);
$message .= "--{$mime_boundary}\r\n" .
"Content-Type: {$fileatt_type};\r\n" .
" name=\"{$fileatt_name}\"\r\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\r\n\n" .
$data . "\r\n\n" .
"--{$mime_boundary}--\r\n";
}
$message = StripSlashes($message);
return(mail($contactemail, $subject, $message, $headers));
}// End of the function send-mail
$sendername=$_POST['txtname'];
$senderemail=$_POST['txtemail'];
$sendersubject=$_POST['txtsubject'];
$sendermessage=$_POST['txtmessage'];
$senderattachtype=$_POST['txtatttype'];
$sendertype=$_POST['rdtype']; // Radio Button Showing Abstract or Paper
$sendertopic=$_POST['ddltopic'];
$sendercontactemail="papersubmission.iwpsd@gmail.c om";
if (send_mail($sendername, $senderemail, $sendercontactemail, $sendersubject, $sendermessage,$senderattachtype,$sendertype,$send ertopic)) {
print "SENT!";
} else {
print "FAILED!";
}
?>
----------------