Bonjour à tous,
je tiens à présiser que j'ai lu pas mal de thread/Faq et autres tutoriel à ce sujet, mais je ne parvient pas à mes fins
Donc voilà je veux faire un mailing à une ou plusieurs adresse avec une ou plusieurs pièces jointes qui peuvent etre de type différent.
Voici le dernier code que j'ai essayé :
voilà ce que je reçoit dans ma boite, en ayant choisie deux fichier et mis dans mon message "j'essaye d'envoyer des pièces jointe"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
44
45
46 $boundary = "-----=".md5(uniqid(rand())); $header = "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$boundary."\"\r\n"; $header .= "\r\n"; $msg = "Je vous informe que ceci est un message au format MIME 1.0.\r\n"; $msg .= "--".$boundary."\r\n"; $msg .= "Content-Type: $type; charset=\"iso-8859-1\"\r\n"; $msg .= "Content-Transfer-Encoding:8bit\r\n"; $msg .= "\r\n"; $msg .= $_POST['msg']; $msg .= "\r\n"; $sql_lst_promo = "select * from document where ID in(".$promo.") order by nom"; $req_lst_promo = mysql_query($sql_lst_promo); while($val_lst_promo = mysql_fetch_array($req_lst_promo)){ $filename = $val_lst_promo['ID']."_doc.".$val_lst_promo['ext']; $fp = fopen("../files/".$filename, 'rb'); $attachment = fread($fp, filesize($file)); fclose($fp); $attachment = chunk_split(base64_encode($attachment)); $msg .= "--".$boundary."\r\n"; $msg .= "Content-Type: ".$filename."; \r"; $msg .= "name=\"".$filename."\"\r\n"; $msg .= "Content-Transfer-Encoding: base64\r\n"; $msg .= "Content-Disposition: inline;\r\n filename=\"".$filename."\"\r\n"; $msg .= $attachment . "\r\n"; $msg .= "\r\n"; $msg .= "\r\n\r\n"; } $msg .= "--".$boundary."--\r\n"; $sql_mailing = "SELECT email_contact FROM client WHERE email_contact<>\"\" and ID in (".$cwhere.")"; $req_mailing = mysql_query($sql_mailing); while($val_mailing = mysql_fetch_array($req_mailing)){ mail($val_mailing[0], $_POST['sujet'] , $msg,"Reply-to: $reponse\r\nFrom: $from\r\n".$header); }
et bien sur il n'y a pas de pièce jointe au mailContent-Type: multipart/mixed; boundary="-----=b70e68019a8bde1c18634be8a4026187"
Je vous informe que ceci est un message au format MIME 1.0.
-------=b70e68019a8bde1c18634be8a4026187
Content-Type: ; charset="iso-8859-1"
Content-Transfer-Encoding:8bit
j'essaye d'envoyer des pièces jointe
-------=b70e68019a8bde1c18634be8a4026187
Content-Type: 2_doc.pdf; name="2_doc.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="2_doc.pdf"
-------=b70e68019a8bde1c18634be8a4026187
Content-Type: 4_doc.2.zip; name="4_doc.2.zip"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="4_doc.2.zip"
-------=b70e68019a8bde1c18634be8a4026187--
merci d'avance
Partager