Hi, ich hab ein Formular, mit einem Datei "Upload". Diese Datei (file1) wird aber nicht irgendwo gespeichert, sondern soll als Attachtment in einem Email versendet werden.
Aber genau dies wird nicht gemacht. Ich bekomme nicht einmal eine leere mail.
Den Code hab ich von irgendwo kopiert und angepasst.
Sieht jemand einen Fehler?
Danke schonmal im Vorraus
<?php
$strEmpfaenger = "exampleEmpf@example.ch";
$strFrom = "exampleFROM@examlpe.ch";
$strSubject = 'Subject EXAMPLE';
$strDelimiter = " = ";
$strMailtext="INHALT von EMAIL";
$file = $file1;
$file_name = $_FILES["file1"]["name"];
$from = $strFrom;
$boundary = strtoupper(md5(uniqid(time())));
$mail_header = "From:Test <$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/octetstream; 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($strEmpfaenger,$strSubject,$strMailtext,$mail_header);
?>