From:
To:
Subject:
Cc:
Bcc:
Body:
File:
'; } ###################################Depois de clicar no send if ($action == "upload") { $mime_list = array("html"=>"text/html","htm"=>"text/html", "txt"=>"text/plain", "rtf"=>"text/enriched","csv"=>"text/tab-separated-values","css"=>"text/css","gif"=>"image/gif"); $ABORT = FALSE; $boundary = "XYZ-" . date(dmyhms) . "-ZYX"; $message = "--$boundary\n"; $message .= "Content-Transfer-Encoding: 8bits\n"; $message .= "Content-Type: text/plain; charset=\"ISO-8859-1\"\n\n"; $message .= $body; $message .= "\n"; #//attachment file names with full path $attachments[1] = $anexo; #$attachments[2] = "c:\etc"; #$attachments[3] = "c:\etc"; //check that the attachment files exist and if so then encode foreach ($attachments as $key => $full_path) { if ($full_path !='') { if (file_exists($full_path)){ //try to open if ($fp = fopen($full_path,"rb")) { //get the file name from the path $filename = array_pop(explode(chr(92),$full_path)); $contents = fread($fp,filesize($full_path)); //encode data $encoded = base64_encode($contents); //*****SPLIT THE ENCODED DATA***** $encoded_split = chunk_split($encoded); fclose($fp); $message .= "--$boundary\n"; $message .= "Content-Type: $anexo_type\n"; $message .= "Content-Disposition: attachment; filename=\"$anexo_name\" \n"; $message .= "Content-Transfer-Encoding: base64\n\n"; $message .= "$encoded_split\n"; } else { echo "Cannot open file$key: $filename"; $ABORT = TRUE; } } else { echo "File$key does not exist: $filename"; $ABORT = TRUE; } } } $message .= "--$boundary--\r\n"; $headers = "MIME-Version: 1.0\n"; $headers .= "From: <$from>\r\n"; $headers .= "Content-type: multipart/mixed; boundary=\"$boundary\"\r\n"; $mensagem=mail($to, $subject, $message, $headers); if ($mensagem) { print "Mensagem enviada!"; } else { print "O envio da mensagem falhou!"; } } ?>