Dovrei inviare una mail con un allegato pdf sia in formato testo che html, non conoscendo com'è configurato il client di posta dei vari utilizzatori.
Ho creato la funzione, però mi invia la mail in formato html divisa in 2. La parte sopra in html, la parte sotto con il testo in plain e 3 allegati. Il pdf che mi serve, un "Parte 1.2" vuoto e un "Parte 1.3" con la parte testo.

Non credo sia corretto....vome devo fare?
Ecco il codice
Grazie

Codice PHP:
$filepdf "file.pdf";
$fp=fopen($prc,"r");
$contents fread($fpfilesize("$prc"));
$encoded_attach chunk_split(base64_encode($contents));
$rand md5(time());

$testo_plain "parte in testo semplice";
$testo_html "parte con tag html";

$boundary "==Multipart_Boundary_x{$rand}x";

$headers "From: mittente\r\n";
$headers .= "\nMIME-Version: 1.0\n";
$headers .=  "Content-Type: multipart/mixed;\n";
$headers .= " boundary=\"{$boundary}\"";

// Email in html
$body .= "This is a multi-part message in MIME format.\n\n";
$body .= "--{$boundary}\n";
$body .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: 7bit\n\n";
$body .= $testo_html "\n\n";
$body .= "--{$boundary}\n";

// Email in testo
$body .= "MIME non supportati\n\n";
$body .= "--{$boundary}\n";
$body .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$body .= "Content-Transfer-Encoding: 7bit\n\n";
$body .= $testo_plain "\n\n";
$body .= "--{$boundary}\n";

$body .= "Content-Disposition: attachment;\n";
$body .= " filename=\"$filepdf\"\n";
$body .= "Content-type: application/pdf name=\"$filepdf\"\n"
$body .= "Content-Transfer-Encoding: base64\n\n";
$body .= $encoded_attach "\n\n";
$body .= "--{$boundary}--\n"