Ir para a pagina inicial dos Grupos do Google    LISTA PHP
Ajuda!! Envio de email com anexo

Vitor de Oliveira <vito...@gmail.com>

Esse meu codigo de envio de email com anexo esta funcionando mas o
anexo nao aparece com a extensão correta aparece . dat e o correto
seria .pdf

Segue abaixo o codigo

<?php                        $from = "cont...@webforte.com.br";
                        $to = "vitor.carva...@hcscomp.com.br";
                        $body = "Corpo do email";
                        $subject = "Assunto do email";

                                $mailheaders = "From: $from\n";
                                $mailheaders .= "X-Mailer: Script para enviar arquivo atachado\n";

                                $msg_body = stripslashes($body);

                                $attach = "xml_xsl.pdf";
                                $attach_size = filesize($attach);
                                $attach_name = "xml_xsl";
                                $attach_type = filetype($attach);

                                $file = fopen($attach, "r");
                                $contents = fread($file, $attach_size);
                                $encoded_attach = chunk_split(base64_encode($contents));
                                fclose($file);

                                $mailheaders .= "MIME-version: 1.0\n";
                                $mailheaders .= "Content-type: multipart/mixed; ";
                                $mailheaders .= "boundary=\"Message-Boundary\"\n";
                                $mailheaders .= "Content-transfer-encoding: 7BIT\n";
                                $mailheaders .= "X-attachments: $attach_name";

                                $body_top = "--Message-Boundary\n";
                                $body_top .= "Content-type: text/plain; charset=US-ASCII\n";
                                $body_top .= "Content-transfer-encoding: 7BIT\n";
                                $body_top .= "Content-description: Mail message body\n\n";

                                $msg_body = $body_top . $msg_body;

                                $msg_body .= "\n\n--Message-Boundary\n";
                                $msg_body .= "Content-type: $attach_type; name=\"$attach_name
\"\n";
                                $msg_body .= "Content-Transfer-Encoding: BASE64\n";
                                $msg_body .= "Content-disposition: attachment; filename=
\"$attach_name\"\n\n";
                                $msg_body .= "$encoded_attach\n";
                                $msg_body .= "--Message-Boundary--\n";

                                $mensagem = mail($to, stripslashes($subject), $msg_body,
$mailheaders);

                        if ($mensagem) {
                                print "E-mail enviado com sucesso!";
                        } else {
                                print "O envio do email falhou!";
                        }
?>