Hallo,
schlage mich seit zwei Tagen mit mail() und Anhang herum.
Verschiedene Scripts ausprobiert, die bei anderen auch funktionieren, bei mir stürzt PHP ab [aus ApacheLog Premature end of script header].
Habe PHP php-4.3.3
Datei liegt im selben Ordner ...
Nutze zB folgendes Script
<?php
$file = "test.xls";
$file_name = "test.xls";
$subject = "Testmail";
$from = "xx@xx.de";
$to = "xy@xy.de
$message = "Dies ist ein Test";
$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";
$file_content = fread(fopen($file,"r"),filesize($file));
$file_content = chunk_split(base64_encode($file_content));
$mail_header .= "\n--$boundary";
$mail_header .= "\nContent-Type: application/x-excel; name="$file_name"";
$mail_header .= "\nContent-Transfer-Encoding: base64";
$mail_header .= "\nContent-Disposition: attachment; filename="$file_name"";
$mail_header .= "\n\n$file_content";
$mail_header .= "\n--$boundary--";
mail($to,$subject,"",$mail_header);
?>