- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
function send_mail ($to, $thm, $html, $path) {
$fp = @fopen ($path, 'r');
if (!$fp) {
print "<p>File $path could not be read</p>";
exit();
}
$file = fread ($fp, filesize ($path));
fclose($fp);
// Generate the separate
$boundary = "--".md5 (uniqid(time ()));
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\n";
$multipart = "--$boundary\n";
$kod = "koi8-r"; // or $kod = "windows-1251";
$mulripart .= "Content-Type: text/html; charset=$kod\n";
$multipart .= "Content-Transfer-Encoding: Quot-Printed\n\n";
$multipart .= "$html\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));
$miltipart .= $message_part."--$boundary--\n";
if (!mail ($to, $thm, $multipart, $headers))
exit("<p>Error sending e-mail</p>");
}