Como faço pra que esse script mande 5 arquivos anexos pro e-mail informado em vez de um só.
Codigo:
<?
#####################################################################
#Baseado na versão 1.0 do script do Alexander Benatti
#Foram utilizados exemplos extraídos do www.php.net
#Este script é GNU - Licensa Pública
#---------------------------------------------------
#Nelson R. Moura
#nelson@sitecom.com.br
###################################Inicia o form
if ($action != "upload")
{
print '
<FORM METHOD="post" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="1000000">
<INPUT TYPE="hidden" NAME="action" VALUE="upload">
<TABLE BORDER="1">
<TR>
<TD>From: </TD>
<TD><input type="text" name="from" size=40><BR></TD>
</TR>
<TR>
<TD>To: </TD>
<TD><input type="text" name="to" size=40><BR></TD>
</TR
<TR>
<TD>Subject: </TD>
<TD><input type="text" name="subject" size=40><BR></TD>
</TR
<TR>
<TD>Cc: </TD>
<TD><input type="text" name="cc" size=40><BR></TD>
</TR
<TR>
<TD>Bcc: </TD>
<TD><input type="text" name="bcc" size=40><BR></TD>
</TR
<TR>
<TD>Body: </TD>
<TD><TEXTAREA NAME="body" ROWS="10" COLS="50"></TEXTAREA></TD>
</TR>
<TR>
<TD>File: </TD>
<TD><INPUT TYPE="file" NAME="anexo"></TD>
</TR>
<TR>
<TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>
</TR>
</TABLE>
</FORM>
';
}
###################################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!";
}
}
?>
Botar Mais Um Arquivo Anexo
Started By Halan, 22/07/2004, 17:56
1 reply to this topic
#1
Posted 22/07/2004, 17:56
:: Nome: Halan S. Batista
:: E-mail: halanb@terra.com.br
:: Especialidade: Web Designer e Web Master
:: Site: www.brasilfest.com.br
--------------------
:: E-mail: halanb@terra.com.br
:: Especialidade: Web Designer e Web Master
:: Site: www.brasilfest.com.br
--------------------
#2
Posted 23/07/2004, 08:42
Coloque mais campos para o envio de arquivos
<INPUT TYPE="file" NAME="anexo">
E altere essas linhas para pegar o caminho para os arquivos
<INPUT TYPE="file" NAME="anexo">
E altere essas linhas para pegar o caminho para os arquivos
#//attachment file names with full path
$attachments[1] = $anexo;
#$attachments[2] = "c:\etc";
#$attachments[3] = "c:\etc";
0 user(s) are reading this topic
0 membro(s), 0 visitante(s) e 0 membros anônimo(s)