heinzflohe: mail() - Attachments

Beitrag lesen

Hallo zusammen!

Habe da ein kleines Problem mit meinem Mail-Script beim versenden mit Anhängen.
Funktioniert alles: Text wird angezeigt, Anhänge sind alle da nur wird bei den Anhängen nochmal eine txt-Datei angezeigt, welche den Mailtext enthält. Aber diese txt-Datei will ich da nicht haben.

Bsp aus Mail-Programm:
Anlage(n): bottom.html (0,58 KB), content.html (7 KB), index.html (0,74 KB), top.html (0,58 KB), text-6.txt (0,00 KB

Script:
##################################Schnipp
<?php

$sessiondir = "../keinetore";

$from = 'Heinz Floheheinzflohe@gmx.de';
$to = "Florian Winklerflo.winkler@t-online.de";
$subject = "Test Mail - 017";
$textemailcontent = 'bbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
ccc
dd
e';

$boundary = md5(uniqid(time()));

$header = "From: $from\n";
$header .= "Reply-To: $from\n";
$header .= "Cc: $cc\n";
$header .= "Bcc: $bcc\n";
$header .= "X-Mailer: PHP/" .phpversion(). "\n";
$header .= "X-Sender-IP: $REMOTE_ADDR\n";
$header .= "MIME-Version: 1.0";
$header .= "\nContent-Type: multipart/mixed; boundary=$boundary";
$header .= "\n\nThis is a multi-part message in MIME format";
$header .= "\n--$boundary";
$header .= "\nContent-Type: text/plain;charset=iso-8859-1";
//$header .= "\nContent-Transfer-Encoding: quoted-printable";
$header .= "\n--$boundary";
$header .= "$textemailcontent";

if (is_dir($sessiondir))
{

$handle=opendir($sessiondir);
while ($file = readdir ($handle))
  {
  if ($file != "." && $file != "..")
   {
      $fp = fopen($sessiondir."/".$file, 'r');
      do //wiederholen bis keine Daten mehr vorhanden sind
       {
       $data = fread($fp, filesize($sessiondir."/".$file));
       if (strlen($data) == 0) break;
       $content .= $data;
       } while (true);
       fclose($fp);

$content_encode = chunk_split(base64_encode($content));
       $content = "";
       $header .= "\n--$boundary";
       $header .= "\nContent-Type: application/octetstream; name="$file"";
       $header .= "\nContent-Transfer-Encoding: base64";
       $header .= "\nContent-Disposition: attachment; filename="$file"";
       $header .= "\n\n$content_encode";
       }
   }
     closedir($handle);
  }
$header .= "\n\n--$boundary";

mail($to,$subject,'',$header);
?>

##################################Schnapp

Danke schon mal für Hilfe, Tipps, Links, etc.

Grüße aus München

Flo