mam skrypt który wysyła maile z załącznikiem do ludzi (mails.txt) problem polega na tym, że plik który dodaję do załącznika (html) pokazuje mi się w np.outlocku jako ciąk znaków w a nie jako strona html, w czym jest błąd?? Jeżeli wiecie stawiam piwo

<?
function fileopenanddecode($file) {
$fd = fopen($file, \"r\"); }
return $encoded;
}
$myMail = \"mail@wp.pl\"; // Zmien na swój adres E-mail
$myName = \"Ktoś\"; // Zmien na swoje imie i nazwisko
$temat = \"temat\";
$writeFile = \"mails.txt\";
$boundary = \"-->===_54654747_===<---->>4255==_\";
$head = \"From: $myName <$myMail>n\";
$head = $head . \"Reply-To: $myMailn\";
$head = $head . \"X-Mailer: phpn\";
$head = $head . \"X-Sender: <$myMail>n\";
$head = $head . \"Return-Path: <$myMail>n\"; // adres zwrotny dla błędów
$head = $head . \"MIME-version: 1.0n\";
$head = $head . \"Content-type: multipart/mixed; \";
$head = $head . \"boundary=\"$boundary\"n\";
$head = $head . \"Content-transfer-encoding: 7BITn\";
$head = $head . \"X-attachments: $filename_name;nn\";
$mesg = \"--\" . $boundary . \"n\"; //pamiętamy dwa minusy na początku
$mesg = $mesg . \"Content-Type: text/plain; charset=\"us-ascii\"nn\";
$mesg = $mesg . $message . \"n\";
$mesg = $mesg . \"--\" . $boundary . \"n\"; //pamiętamy dwa minusy na początku
$mesg = $mesg . \"Content-type: \" . $filename_type . \"; name=\"$filename_name\";n\";
$mesg = $mesg . \"Content-Transfer-Encoding: base64n\";
$mesg = $mesg . \"Content-disposition: attachment; filename= \"$filename_name\"nn\";
$mesg = $mesg . fileopenanddecode($filename) . \"n\"; //czytamy plik i go kodujemy
$mesg = $mesg . \"--\" . $boundary . \"-- n\"; //pamiętamy dwa minusy na początku i na końcu
$mails = file($writeFile); for ($i=0; $i < count($mails); $i++){ mail(\"$mails[$i]\",$temat,$mesg,$head); }
echo \"Wiadomosc zostala wyslana!<br><a href=\"listonosz.php\">Jeszcze raz</a>\"; }
else {
?>
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-2\"></head>
<center>
<form name=\"wysylanie\" method=\"post\" action=\"listonosz.php\" enctype=\"multipart/form-data\">
<table width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td>Wiadomosc:</td><td><textarea name=\"message\" cols=\"60\" rows=\"15\" wrap=\"VIRTUAL\"></textarea></td></tr>
<tr><td>Zalacznik:</td><td><input type=\"file\" name=\"filename\"></td></tr>
<tr><td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"submit\"></td></tr>
</table>
</form>
</center>
</html>
<?php
}
?>