Codice PHP:
<?php
include 'utility/connect.php';
//Nella variabile $mess va inserito tutto il codice html che comporrà il corpo dell'email che si vuole inviare. Come nell'esempio si possono utilizzare anche i fogli di stile.*/
$oggetto=$_POST['oggetto'];
$mittente=$_POST['mittente'];
//$reply="miaemail@email.com";
$titolo=$_FILES['allegato']['name'];
$f=$_FILES['allegato']['tmp_name'];
$filetype=$_FILES['allegato']['type'];
$intestazioni = "From: $mittente\nReply-To: $reply\nX-Mailer: Sismail Web Email Interface\nMIME-version: 1.0\nContent-type: multipart/related;\n boundary=\"Message-Boundary\"\nContent-transfer-encoding: 7BIT\nX-attachments: $titolo";
$filez = fopen($f, "r");
$contents = fread($filez, filesize($f));
$encoded_attach = chunk_split(base64_encode($contents));
fclose($filez);
$msg_body .= "\n\n--Message-Boundary\n";
$msg_body .= "Content-ID: miaimmagine";
$msg_body .= "Content-type: $filetype; name=\"$titolo\"\n";
$msg_body .= "Content-Transfer-Encoding: BASE64\n";
$msg_body .= "Content-disposition: attachment; filename=\"$titolo\"\n\n";
$msg_body .= "$encoded_attach\n";
//$msg_body .= "$encoded_attach";
$body_top .= "Content-type: text/html; charset=iso-8859-1\n";
$body_top .= "Content-transfer-encoding: 7-BIT\n";
$body_top .= "Content-description: Mail message body\n\n";
$body_top .="
<a href=\"\"><img src=\"\"/>" . $msg_body . "</a>";
$mess="MESSAGGIO IN HTML";
//$body_top .= "\n\n--Message-Boundary\n";
$body_top .= "\n\n--Message-Boundary\n";
$body_top .= "Content-type: text/html; charset=iso-8859-1\n";
$body_top .= "Content-transfer-encoding: 7-BIT\n";
$body_top .= "Content-description: Mail message body\n\n";
$body_top .= $mess ;
$sql = "SELECT campo mail FROM tabella;";
$query = mysql_db_query($db_nome, $sql);
while($row = mysql_fetch_assoc($query)){
$destinatario = $row['mail_add'];
$mail_invio = mail($destinatario,$oggetto,$body_top. "Per cancellarsi dalla mail list clicca <a href=\"path http.php?conferma=si&email=$destinatario\">qui</a></body></html> ",$intestazioni);
}
if(!$mail_invio){
header("Location:index.php?verifica=0");
}else{
header("Location:index.php?verifica=1");
}
?>
ciao , io ho scritto questo l'altro gg è funziona.. lo testato e dopo settimane di sclero eccolo qui... prova a vedere se funge anche da te!
ciao