Hi.
Habe folgendes Code:
/////////////////////// anfang //////////////////
$path = "orders/";
$send_pdf = "bestellung_".$newnummer.".pdf";
if($unhappy=true)
{
///////////////////////////////////////
// pdfs
$file = $send_pdf;
$file_name = $send_pdf;
$from = "from@test.de";
$to = "qwerty@qwerty.de";
////////////// message ////////////////////////
// betreff
$subject = "pdf-test";
////////////// message ////////////////////////
$message = "\n\ndrei pdfs als attachment schicken\n\n";
////////////// message ////////////////////////
//////////////// header ///////////////////////
$boundary = strtoupper(md5(uniqid(time())));
$mail_header = "From: <$from>\n";
$mail_header .= "MIME-Version: 1.0";
$mail_header .= "\nContent-Type: multipart/mixed; boundary=$boundary";
$mail_header .= "\n\nThis is a multi-part message in MIME format -- Dies ist eine mehrteilige Nachricht im MIME-Format";
$mail_header .= "\n--$boundary";
$mail_header .= "\nContent-Type: text/plain";
$mail_header .= "\nContent-Transfer-Encoding: 8bit";
$mail_header .= "\n\n$message";
//////////////// header ///////////////////////
//////////////// attachment1 ///////////////////////
$mail_header .= "\n--$boundary";
$mail_header .= "\nContent-Type: application/x-download; name="$file_name"";
$mail_header .= "\nContent-Transfer-Encoding: base64";
$mail_header .= "\nContent-Disposition: attachment; filename="$file_name"";
$file_content = fread(fopen($path.$file,"r"),filesize($path.$file));
$file_content = chunk_split(base64_encode($file_content));
$mail_header .= "\n\n$file_content";
$mail_header .= "\n--$boundary";
//////////////// mail ///////////////////////
$success = mail($to,$subject,$message,$mail_header);
if($success)
{
echo "mail wurde versandt";
echo "email wurde versendet";
}
else
{
echo "email wurde <b>nicht</b> versandt";
}
}
else
{
// wenn es keine datei gibt, gibt es auch nichts zu versenden
echo "keine mail versendet, da es keine datei gibt";
}
/////////////////////// ende //////////////////
Das problem, das die .pdf-datei, die ankommt, ist immer 1KB groß, und ist nucht lesbar. Dutzend andere scripte bringen das gleiche. Woran liegt es?
Danke voraus.