Hi I'm using the following code to send a csv attachment.
Its driving me insane because every attachment has a lot of garbage at the end.
e.g. test4<garbage>
(I cant put the garbage in this textbox.)
$data = "test";
$fileatt_type = "application/octet-stream";
$fileatt_name = "TI_".date("Ymd-Hm")."_".$HTTP_POST_VARS["timake"]."-".$HTTP_POST_VARS['timodel'].".csv";
$email_from = addslashes($HTTP_POST_VARS['email']);
$email_subject = "Trade In Enquiry";
$email_message = $strBody;
$email_to = "al@domain.co.uk";
$headers = "From: ".$HTTP_POST_VARS["first"]." ".$HTTP_POST_VARS["last"]."<".$email_from.">";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n";
$data .= strlen($data);
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n ".$data." \n\n" ."--{".$mime_boundary."}--\n";
$sending_ok = @mail($email_to, $email_subject, $email_message, $headers);