Email mit Dateianhang
|
PHP-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<?php
if(isset($_POST['submit'])) {
## inhalt der file auslesen
$filecontent = fread(fopen($_FILES['datei']['tmp_name'],"r"), filesize($_FILES['datei']['tmp_name']));
## inhalt encodieren
$filecontent = chunk_split(base64_encode($filecontent));
## boundary definieren (der teil der die einzelenen abschnitte
## im email trennt...
$boundary = strtoupper(md5(uniqid(time())));
## definieren des headers...
$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";
$mail_header .= "\n--".$boundary;
$mail_header .= "\nContent-Type: text/plain";
$mail_header .= "\nContent-Transfer-Encoding: 8bit";
$mail_header .= "\n\n".$message;
$mail_header .= "\n--".$boundary;
$mail_header .= "\nContent-Type: application/octetstream; name=\"".$_FILES['datei']['name']."\"";
$mail_header .= "\nContent-Transfer-Encoding: base64";
$mail_header .= "\nContent-Disposition: attachment; filename=\"".$_FILES['datei']['name']."\"";
$mail_header .= "\n\n".$filecontent;
$mail_header .= "\n--".$boundary;
## veschicken der nachricht
mail("empfaenger@doenerstand.at", $subject, $message, "From: [EMAIL]mustafa@doenerstand.at[/EMAIL]\n".$mail_header);
}
?>
|
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »[23]^5^« (3. Februar 2004, 10:57)