pdf bestanden doorsturen in mailscript
ik zit met het volgende, ik wil meerdere pdf bestanden doorsturen in 1 mail.
het huidige mailscript doet het even met 1 bestand.
alleen krijg ik geen pdf doorgestuurd maar een naamloze bijlage 00515.dat en een naamloze bijlage 00518.txt
de url die wordt getoond werkt wel als je hem in de browser plakt
kan iemand mij vertellen wat er mis is aan mijn script? want ik kan het niet vinden.
Alvast bedankt
Jonas
Code (php)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
$to = $_SESSION['clientmail'];
$from = "info@*****.nl";
$subject ="*****.nl Uw Brochures";
$message = "test message brochures";
$headers = "From: $from";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
// preparing attachments
for($x=0;$x<count($files);$x++){
echo($files['listingsfiles_file_name'][$x]);
$file = fopen(("http://www.*******.com/nl/files/listings/188/". $files['listingsfiles_file_name'] ));
echo("http://www.******.com/nl/files/listings/188/".$files['listingsfiles_file_name']);
echo($file);
$data = fread($file,filesize($files[$x]));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
}
// send
$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
echo "<p>Email verstuurd naar $to!</p>";
} else {
echo "<p>De email kon niet worden verstuurd!</p>";
}
?>
$to = $_SESSION['clientmail'];
$from = "info@*****.nl";
$subject ="*****.nl Uw Brochures";
$message = "test message brochures";
$headers = "From: $from";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
// preparing attachments
for($x=0;$x<count($files);$x++){
echo($files['listingsfiles_file_name'][$x]);
$file = fopen(("http://www.*******.com/nl/files/listings/188/". $files['listingsfiles_file_name'] ));
echo("http://www.******.com/nl/files/listings/188/".$files['listingsfiles_file_name']);
echo($file);
$data = fread($file,filesize($files[$x]));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
}
// send
$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
echo "<p>Email verstuurd naar $to!</p>";
} else {
echo "<p>De email kon niet worden verstuurd!</p>";
}
?>
Gewijzigd op 05/02/2011 20:54:48 door Jonas vermeulen
Er zijn nog geen reacties op dit bericht.