venetu
Мой дом здесь!
- Регистрация
- 28 Мар 2007
- Сообщения
- 745
- Реакции
- 273
- Автор темы
- #1
Вот, нарыл такой скриптик, имхо намного удобнее, чем юзать какие-то классы вроде phpMailer.. Все просто и коротко:
PHP:
<?
$attach = './files/file.zip';
$to = "mail@yourdomain.com";
$subj = "Attached file: " . basename($attach);
$mimeBoundary = "boundary_" . md5(uniqid(time()));
$altBoundary = "boundaryAlt_" . md5(uniqid(time()));
$attBoundary = "boundaryAtt_" . md5(uniqid(time()));
$headers = "From: yourmail<mail@yourdomain.com>\r\n";
$headers .= "MIME-version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; boundary="$mimeBoundary"\r\n";
$body = "--" . $mimeBoundary . "\r\n";
$body .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$body .= "Content-transfer-encoding: 7bit\r\n\r\n";
$body .= "<font color=\"red\" face=\"verdana\">HTML Message</font>\r\n\r\n";
$body .= "--" . $mimeBoundary . "\r\n";
$body .= "Content-Type: application/x-zip-compressed; name=" . basename($attach). ".gz\r\n";
$body .= "Content-transfer-encoding: base64\r\n";
$body .= "Content-Disposition: attachment; filename=" . basename($attach). ".gz\r\n\r\n";
$file = file_get_contents($attach);
$file = base64_encode($file);
$file = chunk_split($file);
$body .= $file . "\r\n\r\n";
$body .= "--" . $mimeBoundary . "--\r\n";
mail($to, $subj,$body,$headers);
?>