Probleempje met mail attachment. Onderstaande code werkt helemaal, alleen de attachment (PDF bestand) kan niet door Acrobat Reader geopend worden:

Dat is wel duidelijk, maar welke header zou ik dan moeten gebruiken (i.p.v. "application/pdf")?! Of doe ik toch iets anders fout?
(Ik heb ook dit topic hiervoor gebruikt: [rml][ PHP] MIME attachment voor Hotmail *[/rml])

Dat is wel duidelijk, maar welke header zou ik dan moeten gebruiken (i.p.v. "application/pdf")?! Of doe ik toch iets anders fout?
(Ik heb ook dit topic hiervoor gebruikt: [rml][ PHP] MIME attachment voor Hotmail *[/rml])
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
| // [Create ezPDF file] // [Write ezPDF file] // Read data from file $filename = 'pdf/output.pdf'; $handle = fopen($filename, 'rb'); $data = fread($handle,filesize($filename)); fclose($handle); $data = chunk_split(base64_encode($data)); // Set some mail headers and text $recipient = "..."; $subject = "..."; $message = "Test."; // Create boundary $mimeBoundary = md5(uniqid(time())); // MIME header $header = "MIME-Version: 1.0\r\n"; $header .= "From: ...<...>\r\n"; $header .= "Reply-To: ...\r\n"; $header .= "Content-Type: multipart/mixed;"; $header .= " boundary=\"".$mimeBoundary."\"\r\n"; // MIME message $body = "--".$mimeBoundary."\r\n"; $body .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; $body .= "Content-Transfer-Encoding: 7bit\r\n"; $body .= $message."\r\n"; $body .= "--".$mimeBoundary."\r\n"; // Add attachment $body .= "--".$mimeBoundary."\r\n"; $body .= "Content-Type: application/pdf; name=\"".filename."\"\r\n"; $body .= "Content-Disposition: attachment; filename=\"output.pdf\"\r\n"; $body .= "Content-Transfer-Encoding: base64\n\n"; $body .= $data."\n\n"; $body .= "--".$mimeBoundary."--\r\n\r\n"; // Send mail mail($recipient, $subject, $body, $header); |