Не могу разобраться в заголовках. Письмо приходит без вложения! Целый день потратил на мануалы и поискам информации. Все не подходит! PHP: <?php function send_mail() { $img = chunk_split(base64_encode(file_get_contents('ajax.gif'))); $msg = "sdfbnnfgnasd asdf asdf asdf"; $boundary = "".strtoupper(md5(uniqid(rand()))); $headers = "Date: ". date('D, d M Y h:i:s O') ."\r\n"; $headers .= "From: [email=somemail2@mail.com]somemail2@mail.com[/email]\\rn"; $headers .= "X-Priority: 3\r\n"; $headers .= "Message-ID: <".md5(uniqid(time()))."@mail.com>\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "X-Mailer: PHP ".phpversion()."\r\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"".$boundary."\"\r\n"; $str = "--".$boundary."\r\n"; $str .= "Content-Type: text/plain; charset=utf-8\r\n"; $str .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; $str .= $msg."\r\n\r\n"; $str .= "--".$boundary."\r\n"; $str .= "Content-Type: image/gif;\n name=\"ajax.gif\"\r\n"; $str .= "Content-Disposition: attachment;\n filename=\"ajax.gif\"\r\n"; $str .= "Content-Transfer-Encoding: base64\r\n\r\n"; $str .= $img."\r\n"; $str .= "--".$boundary."--"; $subject = "Hello"; mail([email='somebody@sdf.ru]'somebody@sdf.ru[/email]', $subject, $str, $headers); } send_mail(); ?>
PHP: <? function send_mail($to,$from_mail,$from_name,$subject,$message,$file_name) { $bound="1234"; $header="From: $from_name <$from_mail>\n"; $header.="To: $to\n"; $header.="Subject: $subject\n"; $header.="MIME-Version: 1.0\n"; $header.="Content-Type: multipart/mixed; boundary=$bound\n"; $body="--$bound\n"; $body.="Content-type: text/html; charset=\"windows-1251\"\n"; $body.="Content-Transfer-Encoding: quoted-printable\n\n"; $body.="$message"; $file=file_get_contents($file_name); $body.="\n\n--$bound\n"; $body.="Content-Type: application/octet-stream; "; $body.="name=".basename($file_name)."\n"; $body.="Content-Transfer-Encoding:base64\n"; $body.="Content-Disposition:attachment\n\n"; $body.=base64_encode($file)."\n"; $body.="$bound--\n\n"; if(mail($to, $subject, $body, $header)) { echo "<center>Письмо было успешно отправлено!</center>"; } else { echo "<center>Сообщение не отправлено!</center>"; }; }; ?>