// function to send an attachment function send_mail($mail_to, $thema, $html, $path) { if ($path) { $fp = fopen($path,"rb"); if (!$fp) { print "Cannot open file"; exit(); } $file = fread($fp, filesize($path)); fclose($fp); } $name = $_FILES['mail_file']['name']; // imya fayla bez puti $EOL = "\n"; // ogranichitel' strok $boundary = "--".md5(uniqid(time())); $headers = "MIME-Version: 1.0;$EOL"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"$EOL"; $headers .= "From: geitona@tsompos.com"; $multipart = "--$boundary$EOL"; $multipart .= "Content-Type: text/html; charset=windows-1253$EOL"; $multipart .= "Content-Transfer-Encoding: base64$EOL"; $multipart .= $EOL; // razdel mejdy zagolovkom i telom html-chasti $multipart .= chunk_split(base64_encode($html)); $multipart .= "$EOL--$boundary$EOL"; $multipart .= "Content-Type: application/octet-stream; name=\"$name\"$EOL"; $multipart .= "Content-Transfer-Encoding: base64$EOL"; $multipart .= "Content-Disposition: attachment; filename=\"$name\"$EOL"; $multipart .= $EOL; // razdel mejdy zagolovkom i telom prikl.fayla $multipart .= chunk_split(base64_encode($file)); $multipart .= "$EOL--$boundary--$EOL"; if(!mail($mail_to, $thema, $multipart, $headers)) {return False; //esli NE poslano } else { //// esli poslano return True; } exit; } //// end of function