<?php /* *отправка письма с вложением (attach) *автор: disable *11.09.07 */ $to='example@mail.ru'; $text='текст'; $thm='тема'; //файл $path='example.txt'; $file = file_get_contents($path); // генерируем разделитель $boundary = "--".md5(uniqid(time())); $headers .= "MIME-Version: 1.0\n"; $headers .="Content-Type: multipart/mixed; boundary=\"$boundary\"\n"; $multipart .= "--$boundary\n"; //кодировка $kod = 'utf-8'; $multipart .= "Content-Type: text/plain; charset=$kod\n"; $multipart .= "Content-Transfer-Encoding: Quot-Printed\n\n"; $multipart .= "$text\n\n"; $message_part = "--$boundary\n"; $message_part .= "Content-Type: application/octet-stream\n"; $message_part .= "Content-Transfer-Encoding: base64\n"; $message_part .= "Content-Disposition: attachment; filename = \"$path\"\n\n"; $message_part .= chunk_split(base64_encode($file))."\n"; $multipart .= $message_part."--$boundary--\n"; if(!mail($to, $thm, $multipart, $headers)) { exit("К сожалению, письмо не отправлено"); } ?>