hi all!!!
i have a lil prob with my self made mail function in php....it shows body as an attachment too.....so here is code.....if somebody can help it will b a gr8 deed..plzzz help
<?
function mail($Subject,$Attachments,$Body1,$Body2,$To, $From, $MailType='T')
{ $mime_boundary = "MTWJ_mixed_Bound_0";
$Body1 = str_replace("\r", "", $Body1);
$Body1 = str_replace("\n", "\r\n", $Body1);
$Body2 = str_replace("\r", "", $Body2);
$Body2 = str_replace("\n", "\r\n", $Body2);
$headers ="MIME-Version: 1.0;\r\n";
$headers.="From: $From\r\n";
$headers.= "Content-Type: multipart/alternative;\r\n";
$headers.= " boundary=\"".$mime_boundary."\"\r\n\r\n";
if ($MailType=='T')
{
$message = "--".$mime_boundary."\r\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "\r\n";
$message .= $Body1;
$message .= "\r\n";
//$message .= "--".$mime_boundary."\r\n";
}
elseif($MailType=='H')
{ $message = "--".$mime_boundary."\r\n";
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: base64\n\r\n";
$message .= "\r\n";
$message .= chunk_split(base64_encode($Body2));
$message .= "\r\n";
//$message .= "--".$mime_boundary."\n";
}
elseif($MailType=='H/T')
{
$message = "--".$mime_boundary."\r\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "\r\n";
$message .= $Body1;
$message .= "\r\n";
//$message .= "--".$mime_boundary."\r\n";
$message .= "-----------\n";
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: base64 \r\n\r\n";
$message .= "\r\n";
$message .= chunk_split(base64_encode($Body2));
$message .= "\r\n";
}
foreach($_FILES as $userfile){
// store the file information to variables for easier access
$tmp_name = $userfile['tmp_name'];
$type = $userfile['type'];
$name = $userfile['name'];
$size = $userfile['size'];
// if the upload succeded, the file will exist
if (file_exists($tmp_name)){
// check to make sure that it is an uploaded file and not a system file
if(is_uploaded_file($tmp_name)){
// open the file for a binary read
$file = fopen($tmp_name,'rb');
// read the file content into a variable
$data = fread($file,filesize($tmp_name));
// close the file
fclose($file);
// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
if ($data)
{
$F = explode("/", $name);
$f_name = $F[count($F)-1]; $message .= "--".$mime_boundary."\r\n";
$message .= "Content-Type: application/octet-stream;\r\n"; // For other data $message .= " name=\"$f_name\"\r\n";
$message .= "Content-Disposition: attachment; filename=\"$f_name\"\r\n";
$message .= "Content-transfer-encoding: base64\r\n\r\n";
$message .= "\r\n";
$message .=$data;
$message .= "\r\n";
//$message .= "--".$mime_boundary."\r\n\r\n";
}
}
}
}
return mail($To,$Subject,$message,$headers);
}
?>
please help