Подробней тут http://www.spravkaweb.ru/php/sovet/mail/file
$mailFields = array ( 'TITLE' => 'Тема письма ололо', 'TEXT' => 'Текст ололо', ); $arFile = array ( 0 => $_SERVER['DOCUMENT_ROOT'].'/upload/test.php', 1 => $_SERVER['DOCUMENT_ROOT'].'/robots.txt', ); function sendMessage($mailFields, $arFile) { $subject = '=?windows-1251?B?'.base64_encode($mailFields['TITLE']).'?='; // Subject: =?<кодировка текста>?<способ кодирования>?<закодированный Subject>?= // Кодировка текста = windows-1251 или koi8-r или .... смотря в какой кодировке был текст когда ты его (Subject) кодировал. // Способ кодирования = Q (quoted_printable) или B (base64) // Соответственно функции quoted_printable_encode или base64_encode // Но лучше не изобретать велосипед, а использовать iconv_mime_encode (благо тут уже все придумано). $comment_mail = $mailFields['TEXT']; $arAttachment = array(); if (!empty($arFile)) { foreach($arFile as $file) { $arFile = CFile::MakeFileArray($file); if($arFile){ $file = fopen($arFile['tmp_name'], "r"); $text = fread($file, filesize($arFile['tmp_name'])); fclose($file); $arAttachment[] = array( "attachment" => chunk_split(base64_encode($text)), "name" => $arFile["name"], "type" => $arFile["type"], "arFile" => $arFile, ); } } } $boundary = '#####' . time(); $sStartOrEndLetter = '--'; $sImplode = "\r\n"; $sHeader = ''; $sHeader.= 'From: "Ололий" <ololo@ololo.com>'.$sImplode; $sHeader.= 'To: ololo@ololo.com'.$sImplode; $sHeader.= 'Subject: '.$subject.$sImplode; $sHeader.= 'Mime-Version: 1.0'.$sImplode; $sHeader.= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$sImplode; $sMessage = ''; $sMessage.= $sStartOrEndLetter.$boundary.$sImplode; $sMessage.= 'Content-type: text/plain; charset="windows-1251"'.$sImplode; $sMessage.= 'Content-Transfer-Encoding: quoted-printable'.$sImplode; $sMessage.= "\n"; $sMessage.= $comment_mail; $sMessage.= "\n\n"; if(count($arAttachment) > 0){ foreach($arAttachment as $attachment){ $sMessage.= $sStartOrEndLetter.$boundary.$sImplode; $sMessage.= 'Content-Type: application/x-rar-compressed; name="'.$attachment['name'].'"'.$sImplode; $sMessage.= 'Content-Transfer-Encoding:base64'.$sImplode; $sMessage.= 'Content-Disposition:attachment;'.$sImplode; $sMessage.= $sImplode; $sMessage.= $attachment['attachment']; $sMessage.= $sImplode; } } $sMessage.= $sStartOrEndLetter.$boundary.$sStartOrEndLetter.$sImplode; // echo "<pre>"; // print_r($sHeader); // print_r($sMessage); // echo "</pre>"; if(mail('ololo@ololo.com', $subject, $sMessage, $sHeader) ){ print_r('cool'); }else{ print_r('bad'); } }