Hi Guys
Im using the following to send a text file as an attachment, the file is about 10kb all works fine, email is sent & received inc the attachment but the attached file is blank it removes all the text.
Can anyone help please ?
<?php
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$name = basename($file);
$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "Reply-To: ".$replyto."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
if (mail($mailto, $subject, "", $header)) {
echo "ok";
} else {
echo "error";
}
}
// how to use
$my_file = "06-January-2006.txt";
$my_path = "C:/files/";
$my_name = "Myname";
$my_mail = "myemail@address.com";
$my_replyto = "";
$my_subject = "Backup";
$my_message = "no Message";
mail_attachment($my_file, $my_path, "sendto@theiremail.com", $my_mail, $my_name, $my_replyto, $my_subject, $my_message);
?>
Thanx guys