Ik heb een scriptje gemaakt om mime-mail mee te verzenden: hij verstuurt plain text en html-geformatteerde tekst met een embedded plaatje.
Het gaat bijna goed, op 2 dingen na:
1. outlook express toont een attachment-icoontje terwijl het plaatje getoond wordt in het mailtje. in outlook gaat het wel goed. dit probleem ontstond pas nadat ik de scheiding plain/html had aangebracht.
2. in de webmail van ons bedrijf zie ik zowel de platte tekst als de geformatteerde; in mijn eigen webmail zie ik alleen de platte tekst, maar krijg ik de geformatteerde tekst en het plaatje als attachment.
nou heb ik twee vragen:
weet iemand waar dit aan ligt?
hoe noodzakelijk is het om de scheiding plain/html aan te brengen?
Het gaat bijna goed, op 2 dingen na:
1. outlook express toont een attachment-icoontje terwijl het plaatje getoond wordt in het mailtje. in outlook gaat het wel goed. dit probleem ontstond pas nadat ik de scheiding plain/html had aangebracht.
2. in de webmail van ons bedrijf zie ik zowel de platte tekst als de geformatteerde; in mijn eigen webmail zie ik alleen de platte tekst, maar krijg ik de geformatteerde tekst en het plaatje als attachment.
nou heb ik twee vragen:
weet iemand waar dit aan ligt?
hoe noodzakelijk is het om de scheiding plain/html aan te brengen?
PHP:
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
| <? $to = "iemand@adres.com"; $naam = "naam van afzender"; $from = "iemand@ergens.com"; $subject = "test formattedMail"; $arrHeaders = array(); $arrBodyparts = array(); $bodyPlain = "platte bodytekst"; $body = "<b>bodytekst</b><br>"; $body .= "[img]'cid:uniekeIDvoorMijnPlaatje'[/img]"; //------------------ plaatje encoden $fileNaam = "plaatje.gif"; $filePointer = fopen($fileNaam,"r") or die ("niet geopend"); $fileEncoded = fread($filePointer, filesize($fileNaam)); $fileEncoded = chunk_split(base64_encode($fileEncoded)); //----------------- definieer headers $arrHeaders[] = "From: ".$naam." <".$from.">"; //----------------- definieer mime-headers $arrHeaders[] = "MIME-Version: 1.0"; $boundaryAlternative = md5(uniqid(time())); $boundaryRelated = md5(uniqid(time())); $arrHeaders[] = "Content-Type: multipart/alternative; boundary=\"".$boundaryAlternative."\"\r\n"; $headers = implode ("\r\n",$arrHeaders); //------------------ definieer body //plain text $arrBodyparts[] = "--".$boundaryAlternative; $arrBodyparts[] = "Content-Type: text/plain; charset=us-ascii"; $arrBodyparts[] = "Content-Transfer-Encoding: 7bit\r\n"; $arrBodyparts[] = $bodyPlain."\r\n"; //html-formatted $arrBodyparts[] = "--".$boundaryAlternative; $arrBodyparts[] = "Content-Type: multipart/related; boundary=\"".$boundaryRelated."\"\r\n"; $arrBodyparts[] = "--".$boundaryRelated; $arrBodyparts[] = "Content-Type: text/html; charset=us-ascii"; $arrBodyparts[] = "Content-Transfer-Encoding: 7bit\r\n"; $arrBodyparts[] = $body."\r\n"; //nu attachments $arrBodyparts[] = "--".$boundaryRelated; $arrBodyparts[] = "Content-Type: image/gif; name=\"".$fileNaam."\""; $arrBodyparts[] = "Content-Transfer-Encoding: base64"; $arrBodyparts[] = "Content-ID: uniekeIDvoorMijnPlaatje"; $arrBodyparts[] = "Content-Disposition: inline; filename=\"".$fileNaam."\"\r\n"; $arrBodyparts[] = $fileEncoded."\r\n"; //bodyparts afsluiten $arrBodyparts[] = "--".$boundaryRelated."--\r\n"; $arrBodyparts[] = "--".$boundaryAlternative."--"; $body = implode ("\r\n",$arrBodyparts); mail ($to, $subject, $body, $headers); ?> |