Codice PHP:
if($allegato1_name!="") {
$file_dir = "allegati";
move_uploaded_file ($allegato1, "allegati/$allegato1_name") or die ("Impossibile uplodare il file sul server");
$titolo1=$allegato1_name;
$f1="/home/creativa/public_html/vladimiro/allegati/$allegato1_name";
$filez1 = fopen($f1, "r");
$contents1 = fread($filez1, filesize($f1));
$encoded_attach1 = chunk_split(base64_encode($contents1));
fclose($filez1);
}
if($allegato2_name!="") {
$file_dir = "allegati";
move_uploaded_file ($allegato2, "allegati/$allegato2_name") or die ("Impossibile uplodare il file sul server");
$titolo2=$allegato2_name;
$f2="/home/creativa/public_html/vladimiro/allegati/$allegato2_name";
$filez2 = fopen($f2, "r");
$contents2 = fread($filez2, filesize($f2));
$encoded_attach2 = chunk_split(base64_encode($contents2));
fclose($filez2);
}
if($allegato3_name!="") {
$file_dir = "allegati";
move_uploaded_file ($allegato3, "allegati/$allegato3_name") or die ("Impossibile uplodare il file sul server");
$titolo3=$allegato3_name;
$f3="/home/creativa/public_html/vladimiro/allegati/$allegato3_name";
$filez3 = fopen($f3, "r");
$contents3 = fread($filez3, filesize($f3));
$encoded_attach3 = chunk_split(base64_encode($contents3));
fclose($filez3);
}
$boundary = md5(uniqid(microtime()));
$variad=array($_POST['valori']);
foreach($variad as $valu){
foreach($valu as $keyg){
$searchf = "SELECT * from agenzie where id='$keyg'";
$queryf = mysql_query($searchf);
$dataf = mysql_fetch_array($queryf);
$intestazioni="From: $mittente<$email>\nX-Mailer: Sismail Web Email Interface\nMIME-version: 1.0\nContent-type: multipart/mixed;\n boundary=\"Message-Boundary\"\nContent-transfer-encoding: 7BIT\nX-attachments: $titolo1 $titolo2 $titolo3";
$body_top = "--Message-Boundary\n";
$body_top .= "Content-type: text/html; charset=iso-8859-1\n";
$body_top .= "Content-transfer-encoding: 8BIT\n";
$body_top .= "Content-description: Mail message body\n\n";
$to = "$dataf[email]";
$subject = $oggetto;
$message = $body;
$msg_body = $body_top . $message;
if($allegato1_name!="") {
$msg_body .= "\n\n--Message-Boundary\n";
$msg_body .= "Content-type: $allegato1_type; name=\"$titolo1\"\n";
$msg_body .= "Content-Transfer-Encoding: BASE64\n";
$msg_body .= "Content-disposition: attachment; filename=\"$titolo1\"\n\n";
$msg_body .= "$encoded_attach1\n";
$msg_body .= "--Message-Boundary--\n";
}
if($allegato2_name!="") {
$msg_body .= "\n\n--Message-Boundary\n";
$msg_body .= "Content-type: $allegato2_type; name=\"$titolo2\"\n";
$msg_body .= "Content-Transfer-Encoding: BASE64\n";
$msg_body .= "Content-disposition: attachment; filename=\"$titolo2\"\n\n";
$msg_body .= "$encoded_attach2\n";
$msg_body .= "--Message-Boundary--\n";
}
if($allegato3_name!="") {
$msg_body .= "\n\n--Message-Boundary\n";
$msg_body .= "Content-type: $allegato3_type; name=\"$titolo3\"\n";
$msg_body .= "Content-Transfer-Encoding: BASE64\n";
$msg_body .= "Content-disposition: attachment; filename=\"$titolo3\"\n\n";
$msg_body .= "$encoded_attach3\n";
$msg_body .= "--Message-Boundary--\n";
}
mail("$to","$subject",$msg_body, $intestazioni);
Fammi sapere cosa sbaglio e grazie