Hi,
folgendes Problem: ich versuche per PHP eine Anhang mitzusenden, dieser kommt auch in der Mail an, aber bekomme immer die Fehlermeldung: Datei beschädigt. Jemand eine Idee? Danke.
folgendes Problem: ich versuche per PHP eine Anhang mitzusenden, dieser kommt auch in der Mail an, aber bekomme immer die Fehlermeldung: Datei beschädigt. Jemand eine Idee? Danke.
PHP:
<?php
if (!empty($_POST)) {
// get the posted data
$name = $_POST['name'];
$adress = $_POST['adress'];
$telefon = $_POST['telefon'];
$mobil = $_POST['mobil'];
$fax = $_POST['fax'];
$email_address = $_POST['email'];
$stelle = $_POST['stelle'];
$arbeit = $_POST['optionsRadios'];
$email_subject = "XXX";
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
$filename = $_FILES['file']['name'];
$boundary =md5(date('r', time()));
$message = strip_tags($_POST['message']);
$to = 'xxx@xxx.de';
// write the email content
$headers = "From: xx@xxx.de\r\nReply-To: xx@xxx.de";
$headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
$message="This is a multi-part message in MIME format.
--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
--_2_$boundary
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
--------------------------------
--------------------------------
Mitarbeit: $arbeit
Stelle: $stelle
Name: $name
Adresse: $adress
Telefon: $telefon
Mobil: $mobil
Fax: $fax
E-Mail: $email_address
--------------------------------
--------------------------------
--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--_1_$boundary--";
}
?>