eccolo qua Funcool
Codice PHP:
<?
$to = "tuamail@nomesito.dominio";
$subject = "Fotomontaggio $marca $modello da $nick";
# MEMORIZZIAMO NELLA VARIABILE $file_content IL CONTENUTO DEL FILE
$file_content = $_FILES['file']['tmp_name'];
$file_name = $_FILES['file']['name'];
$file_type = $_FILES['file']['type'];
$file_size = $_FILES['file']['size'];
$file2_content = $_FILES['file2']['tmp_name'];
$file2_name = $_FILES['file2']['name'];
$file2_type = $_FILES['file2']['type'];
$file2_size = $_FILES['file2']['size'];
if ($file_size <= 300000 && $file2_size <= 300000){ ## se l'attach è al max 300 kbyte allora spedisco
#### imposto l'email e la spedisco ####
$mail_boundary = md5(uniqid(time()));
$mail2_boundary = md5(uniqid(time()));
$mail_headers .= "X-Priority: 1 (Highest)\n";
$mail2_headers .= "X-Priority: 1 (Highest)\n";
$mail_headers .= "MIME-Version: 1.0\r\n";
$mail2_headers .= "MIME-Version: 1.0\r\n";
$mail_headers .= "Content-type: multipart/mixed; boundary=\"$mail_boundary\"";
$mail2_headers .= "Content-type: multipart/mixed; boundary=\"$mail2_boundary\"";
$mail_headers .= "\r\n\r\n";
$mail2_headers .= "\r\n\r\n";
$mail_headers .= "This is a multi-part message in MIME format. ";
$mail2_headers .= "This is a multi-part message in MIME format. ";
$mail_headers .= "\r\n\r\n";
$mail2_headers .= "\r\n\r\n";
#$mail_headers .= "X-Mailer: PHP/" . phpversion();
#$mail2_headers .= "X-Mailer: PHP/" . phpversion();
$file = fread(fopen($file_content, "r"), $file_size);
$file = chunk_split(base64_encode($file));
$file2 = fread(fopen($file2_content, "r"), $file2_size);
$file2 = chunk_split(base64_encode($file2));
$mail_body = "--$mail_boundary\n";
$mail_body .= "Content-type:text/plain; charset=US-ASCII\r\n";
$mail_body .= "Content-transfer-encoding:8 bit\r\n\r\n";
$mail_body .= "Ricevuto da: $nick\n\n\n\n";
$mail_body .= "Fotomontaggio: $marca\n\n\n\n";
$mail_body .= "Modello: $modello\n\n\n\n";
$mail_body .= "--$mail_boundary\n";
$filename = basename($file_name);
$file2name = basename($file2_name);
$mail_body .= "Content-type:application/octet-stream; name=$filename\r\n";
$mail_body .= "Content-transfer-encoding:base64\r\n\r\n";
$mail_body .= $file. "\r\n\r\n";
$mail_body .= "Content-type:application/octet-stream; name=$file2name\r\n";
$mail_body .= "Content-transfer-encoding:base64\r\n\r\n";
$mail_body .= $file2. "\r\n\r\n";
$mail_body .= "--$mail_boundary--\r\n";
$ris = mail("$to", $subject, $mail_body, $mail_headers, $mail2_headers);
if ($ris){
print "
<div align=\"center\">
<h2>Fotomontaggio $marca $modello è stato inviato con successo!</h2>
</div>";
}
else {
print "
<div align=\"center\">
<h2>Il Fotomontaggio NON è stato spedito!</h2>
</div>";
}
}
else { ## se l'attach supera i 300 kbyte allora NON spedisco
print "
<div align=\"center\">
<h2> Errore Fotomontaggio è maggiore di 300 kByte!</h2>
</div>";
}
?>