<?php $acao = $_GET["acao"]; if ($acao == "enviar") { $nome = $_POST["NOME"]; $assunto = $_POST["ASSUNTO"]; $remetente = $_POST["EMAIL"]; $destino = $_POST["OPCOES"]; $mensagem = $_POST["TEXTO"]; $mensagem = wordwrap($mensagem,50,"<br>",1); $arquivo = isset($_FILES["ARQUIVO"]) ? $_FILES["ARQUIVO"] : FALSE; if (file_exists($arquivo["tmp_name"]) and !empty($arquivo)) { $fp = fopen($_FILES["ARQUIVO"]["tmp_name"],"rb"); $anexo = fread($fp,filesize($_FILES["ARQUIVO"]["tmp_name"])); $anexo = base64_encode($anexo); fclose($fp); $anexo = chunk_split($anexo); $boundary = "XYZ-" . date("dmYis") . "-ZYX"; $texto = "--$boundary\n"; $texto .= "Content-Transfer-Encoding: 8bits\n"; $texto .= "Content-Type: text/html; charset=\"ISO-8859-1\"\n\n"; $texto .= "$mensagem\n"; $texto .= "--$boundary\n"; $texto .= "Content-Type: ".$arquivo["type"]."\n"; $texto .= "Content-Disposition: attachment; filename=\"".$arquivo["name"]."\"\n"; $texto .= "Content-Transfer-Encoding: base64\n\n"; $texto .= "$anexo\n"; $texto .= "--$boundary--\r\n"; $headers = "MIME-Version: 1.0\n"; $headers .= "From: \"$nome\" <$remetente>\r\n"; $headers .= "Content-type: multipart/mixed; boundary=\"$boundary\"\r\n"; $headers .= "$boundary\n"; $Enviar=mail($destino,$assunto,$texto,$headers); echo"Email enviado com Sucesso!"; } else { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"$nome\" <$remetente>\r\n"; $Enviar=mail($destino,$assunto,$mensagem,$headers); echo"Email enviado com Sucesso!"; } } ?>
Obriagdo!