Questo codice permetterebbe in teoria di spedire email html con allegato solo che la parte dell'allegato non mi funge.
Cioè l'allegato viene spedito.il destinatario vede l'allegato ma non riesce ad aprirlo, come mai?
<?
$mess= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<HTML><HEAD>
<META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">
<STYLE>
H5 {text-align: justify; text-decoration: none; color: #333333; font-size: 12px; font-family: Arial}
A:link, A:visited, A:hover { color: #FFcc00 }
</STYLE>
</HEAD>
<BODY bgColor=#ffffff link=#333333 alink=#333333 vlink=#333333>
<DIV><h5>BLA BLA BLA BLA. Questo è il corpo dell'email; si possono usare tutti i tag html, come se si trattasse di una pagina internet.</h5>
</BODY></HTML>
";
$e="destinatario@email.it";
$ogg="Oggetto dell'email";
$mittente="miaemail@email.com";
$reply="miaemail@email.com";
$titolo="allegato.pdf";
$f="file.pdf";
$filetype="application/pdf";
/*Non modificare nulla al di sotto di questa linea*/
$intestazioni = "From: $mittente\nReply-To: $reply\nX-Mailer: Sismail Web Email Interface\nMIME-version: 1.0\nContent-type: multipart/mixed;\n boundary=\"Message-Boundary\"\nContent-transfer-encoding: 7BIT\nX-attachments: $titolo";
$body_top = "--Message-Boundary\n";
$body_top .= "Content-type: text/html; charset=iso-8859-1\n";
$body_top .= "Content-transfer-encoding: 7BIT\n";
$body_top .= "Content-description: Mail message body\n\n";
$msg_body = $body_top . $mess;
$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-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 .= "--Message-Boundary--\n";
if(!(@mail($e,$ogg,$msg_body, $intestazioni))){
print "<H5>Invio della email fallito.</H5>";}
?>