Ho recuperato un piccolo script da internet che dovrebbe inviare al volo un file PDF generato con FPDF il codice è questo:

Codice PHP:
define('FPDF_FONTPATH','../../utils/fpdf/font/');
require(
'../../utils/fpdf/fpdf.php');

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont("Arial","B",14);
$pdf->Cell(40,10"this is a pdf example");

$to "test@myown.it"
$from "noreply@myown.it"
$subject "send email with pdf attachment"
$message "

Please see the attachment.</p>"
;

$separator md5(time());
$eol PHP_EOL;
$filename "example.pdf";
$pdfdoc $pdf->Output("""S");

$attachment chunk_split(base64_encode($pdfdoc));

$headers  "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/pdf; name=\"".$filename."\"".$eol
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";

mail($to$subject$message$headers); 
Il problema è che il risultato arriva si allegato alla mail ma è troncato della testa come potete vedere in questo screenshot:



Secondo voi come posso correggere questa problematica?

Grazie 1000.