
<? if ($action == \"send\") { $header = \"From: \" . $from . \"n\"; if ($attachement != \"none\") { // Get attachement type $type = $HTTP_POST_FILES[attachement][type]; if (($type == \"text/plain\") || ($type == \"text/html\")) $encoding = \"8bit\"; else $encoding = \"base64\"; // Get attachement content /* $fp = @fopen($HTTP_POST_FILES[attachement][tmp_name],\"r\"); if (!$fp) { print \"Could not open attachment for reading...<br>n\"; print \"Exiting script!<br><br>\"; print \"No mail has been sent!\"; exit; } // if encoding is base64 ... encode it if ($encoding == \"base64\") // create a unqiue boundary // create the message header... $header .= \"MIME-version: 1.0n\"; $header .= \"Content-Type: multipart/mixed;n\"; $header .= \"tboundary= \" . $boundary . \"nn\"; $header .= \"This is a multi-part message in MIME format.nn\"; // create the message body in the header $header .= \"--\" . $boundary . \"n\"; $header .= \"Content-Type: \" . $ct . \";n\"; $header .= \"tcharset=\"iso-8859-1\"n\"; $header .= \"Content-Transfer-Encoding: quoted-printablenn\"; // actual message $header .= $body . \"nn\"; // now for the attachement $header .= \"--\" . $boundary . \"n\"; $header .= \"Content-Type: \" . $type . \"n\"; $header .= \"Content-Transfer-Encoding: \" . $encoding . \"n\"; $header .= \"Content-Disposition: attachment; filename=\"\" . $HTTP_POST_FILES[attachement][name] . \"\"nn\"; // actual attachement $header .= $file_content . \"nn\"; $header .= \"--\" . $boundary . \"--\"; } else // if there is no attachement... { $header .= \"Content-Type: \" . $ct . \";n\"; $header .= \"tcharset=\"iso-8859-1\"n\"; $header .= \"Content-Transfer-Encoding: quoted-printablenn\"; // actual message $header .= $body . \"nn\"; } else } else { ?> <html> <head> <title>Mail Attachement</title> </head> <body bgcolor=\"#FFFFFF\"> <center> <form enctype=\"multipart/form-data\" action=\"1.php\" method=\"POST\"> <input type=\"hidden\" name=\"action\" value=\"send\"> <table width=\"500\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"> <tr> <td width=\"150\" align=\"left\" valign=\"center\"> <font face=\"Verdana,Tahoma,Arial,Helvetica\" size=\"2\" color=\"#000000\"> To: </font> </td> <td width=\"350\" align=\"left\" valign=\"center\"> <input type=\"text\" size=\"40\" name=\"to\"> </td> </tr> <tr> <td width=\"150\" align=\"left\" valign=\"center\"> <font face=\"Verdana,Tahoma,Arial,Helvetica\" size=\"2\" color=\"#000000\"> From: </font> </td> <td width=\"350\" align=\"left\" valign=\"center\"> <input type=\"text\" size=\"40\" name=\"from\"> </td> </tr> <tr> <td width=\"150\" align=\"left\" valign=\"center\"> <font face=\"Verdana,Tahoma,Arial,Helvetica\" size=\"2\" color=\"#000000\"> Subject: </font> </td> <td width=\"350\" align=\"left\" valign=\"center\"> <input type=\"text\" size=\"40\" name=\"subject\"> </td> </tr> <tr> <td width=\"150\" align=\"left\" valign=\"center\"> <font face=\"Verdana,Tahoma,Arial,Helvetica\" size=\"2\" color=\"#000000\"> Content type: </font> </td> <td width=\"350\" align=\"left\" valign=\"center\"> <select name=\"ct\"> <option value=\"text/plain\">Plaintext</option> <option value=\"text/html\">HTML mail</option> </select> </td> </tr> <tr> <td width=\"150\" align=\"left\" valign=\"top\"> <font face=\"Verdana,Tahoma,Arial,Helvetica\" size=\"2\" color=\"#000000\"> Message body: </font> </td> <td width=\"350\" align=\"left\" valign=\"top\"> <textarea rows=\"8\" cols=\"38\" name=\"body\"></textarea> </td> </tr> <tr> <td width=\"150\" align=\"left\" valign=\"center\"> <font face=\"Verdana,Tahoma,Arial,Helvetica\" size=\"2\" color=\"#000000\"> Attachement: </font> </td> <td width=\"350\" align=\"left\" valign=\"center\"> <input type=\"file\" name=\"attachement\"> </td> </tr> <tr> <td width=\"150\" align=\"left\" valign=\"center\"> <font face=\"Verdana,Tahoma,Arial,Helvetica\" size=\"2\" color=\"#000000\"> </font> </td> <td width=\"350\" align=\"left\" valign=\"center\"> <input type=\"submit\" value=\"Send\"> </td> </tr> </table> </center> </form> </body></html> <? } ?>
niestety wywala mi błąd:
Warning: fread(): supplied argument is not a valid stream resource in /home/xxxc/public_html/test/1.php on line 22
Mail sent!
mail dochodzi z załącznikiem ale nie moge go otworzyć

wydaje się być uszkodzony

i jak zrobić by wyświetlał polskie znaczki w treści wiadomości ?
proszę o pomoc
