\n"; $mail_header .= "To: <$to> \n"; $mail_header .= "Subject: $subject\n"; $mail_header .= "MIME-Version: 1.0"; $mail_header .= "\nContent-Type: multipart/mixed; boundary=\"$boundary\";"; //-> "text der boundry" $mail_header .= "\n\nThis is a multi-part message in MIME format -- Dies ist eine mehrteilige Nachricht im MIME-Format"; $mail_header .= "\nContent-Transfer-Encoding: 8bit"; $mail_header .= "\nThis part of the E-mail should never be seen. If you are reading this, consider upgrading your e-mail client to a MIME-compatible client."; # commencement of mail-text part... $mail_header .= "\n--$boundary"; $mail_header .= "\nContent-Type: text/plain; charset=\"iso-8859-1\""; $mail_header .= "\nContent-Transfer-Encoding: 8bit"; $mail_header .= "\n\n$msg\n"; # commencement of attachment part... if (!mail_file_attachment($file, $boundary, &$mail_header)) return false; # print ending of email... $mail_header .= "\n--$boundary--"; $ReWert = mail($to, $subject, "", $mail_header); return ReWert; } /*------------------------------------------------------------------ FUNCTION: mail_file_attachment erstellt ein e-Mail Attachment aus einer oder mehr Datei/-en. Wenn mehrere Dateien angegeben werden, so sind die Pfade der Dateien in einem Array zu uebergeben. IN/OUTPUTS: - $file: Pfad des zu sendenden Files. Sind mehrere Files zum senden, so sind die Pfade in einem Array zu uebergeben. - $boundary: Boundary des e-Mails - $header_attach; Pointer zu den Attachment Daten - ReturnWert: TRUE oder FALSE ERSTELLT: A. Gurtner 12.05.02 GEAENDERT: Lexu 24.10.2004 (Dem stand der Zeit angepasst) ------------------------------------------------------------------*/ function mail_file_attachment($file, $boundary, &$header_attach) { $attached_files = 0; if (gettype($file) == "array") { $count_files = count($file); while ($attached_files < $count_files) { if (!mail_addfile($file[$attached_files], $header_attach, $boundary)) return FALSE; $attached_files++; } } else if (gettype($file) == "string") { # add current fiel to mail if (!mail_addfile($file, $header_attach, $boundary)) return FALSE; $attached_files++; } else return FALSE; // if no file was attached!!! if ($attached_files < 1) return FALSE; return TRUE; } // --- ENDE --- /*------------------------------------------------------------------ FUNCTION: mail_addfile Hängt die Dateien an einer Mail an. IN/OUTPUTS: - $file: Pfad des zu sendenden Files. Nur das jeweilige, keine Arrays mehr! - $boundary: Boundary des e-Mails - $header_attach; Pointer zu den Attachment Daten ERSTELLT: A. Gurtner 24.10.2004 GEAENDERT: - ------------------------------------------------------------------*/ function mail_addfile($file, &$header_attach, $boundary) { # Ist das Ding ein File? if (strlen($file) < 1) return FALSE; if (!file_exists($file)) return FALSE; $file_content = fread(fopen($file,"r"),filesize($file)); $file_basename = basename($file); $file_type="image/jpeg"; # encode file to BASE64... $file_content = chunk_split(base64_encode($file_content)); $header_attach .= "\n--$boundary\n"; $header_attach .= "Content-Type: $file_type; name=\"$file_basename\";\n"; $header_attach .= "Content-Transfer-Encoding: base64 \n"; $header_attach .= "Content-Disposition: attachment; filename=\"$file_basename\"\n\n"; $header_attach .= $file_content . "\n"; return TRUE; } ?>