Приветствую Всех!
Возникла проблема, пытаюсь отправить письмо со вложением на почту с localhost (win7, apache) пишет, что отправлено (выдает true), а на почте писем нет, проверял и на почту mail.ru и на gmail.com - один и тот же результат.
Вот сам код:
<?php
function mail_attach($to, $from, $subj, $text, $files = null, $isHTML = false)
{
$boundary = "------------" . strtoupper(md5(uniqid(rand())));
$headers = "From: " . $from . "\r\n
X-Mailer: koz1024.net\r\n
MIME-Version: 1.0\r\n
Content-Type: multipart/alternative;boundary=\"$boundary\"\r\n\r\n
";
if (!$isHTML) {
$type = 'text/plain';
} else {
$type = 'text/html';
}
$body = $boundary . "\r\n\r\n
Content-Type:" . $type . "; charset=utf-8\r\n
Content-Transfer-Encoding: 8bit\r\n\r\n
" . $text . "\r\n\r\n";
if ((is_array($files)) && (!empty($files))) {
foreach ($files as $filename => $filecontent) {
$body .= $boundary . "\r\n
Content-Type: application/octet-stream;name=\"" . $filename . "\"\r\n
Content-Transfer-Encoding:base64\r\n
Content-Disposition:attachment;filename=\"" . $filename . "\"\r\n\r\n
" . chunk_split(base64_encode($filecontent));
}
}
return mail($to, $subj, $body, $headers);
}
$files = array(
'archive.zip' => file_get_contents('files/archive.zip')
);
if (mail_attach('vitalik.tjuryakin@gmail.com', 'attach@text.com', 'Test 1', 'Hello attach...', $files, false)) {
echo true;
} else {
echo false;
}
?>
Вставлял в начале: error_reporting(E_ALL);
- так же, ошибок не обнаружено.