Guten Abend,
der Versand von Emails mit 1 Anhang funktioniert wunderbar. Hier mein Script:
Nun möchte ich aber 2 oder 3 Dateien als Anhang versenden. Wie ändere ich das Script? Wer kann mir bitte kurz helfen?
Thx
Klaus06
der Versand von Emails mit 1 Anhang funktioniert wunderbar. Hier mein Script:
PHP-Code:
$file = "bilder/anfragen/$bild_name_neu1";
$file_name = "$bild_name_neu1";
$file_content = fread(fopen($file,"r"),filesize($file));
# encode file to BASE64...
$file_content = chunk_split(base64_encode($file_content));
# generate boundary...
$boundary = strtoupper(md5(uniqid(time())));
# commencement of Mail-Header with MIME-Mail-Header...
$mail_header = "From:$from\n";
$mail_header .= "CC:$cc\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";
# commencement of mail-text part...
$mail_header .= "\n--$boundary";
$mail_header .= "\nContent-Type: text/plain";
$mail_header .= "\nContent-Transfer-Encoding: 8bit";
$mail_header .= "\n\n$message";
# commencement of attachement...
$mail_header .= "\n--$boundary";
$mail_header .= "\nContent-Type: application/octetstream; name=\"$file_name\"";
# encode file to BASE64...
$mail_header .= "\nContent-Transfer-Encoding: base64";
$mail_header .= "\nContent-Disposition: attachment; filename=\"$file_name\"";
$mail_header .= "\n\n$file_content";
# print ending of email...
$mail_header .= "\n--$boundary--";
if ( empty ($php_errormsg) )
{
# send mail with attachment...
$mail_result = mail($to,$subject,"",$mail_header);
}
Thx
Klaus06