Bonjour à tous,
Je viens vers vous car j'ai un souci avec l'envoi de mail en php, je vous explique.
J'utilise une class php SMTP pour l'envoi de mail avec pièce jointe, tout ce passe bien, sauf que j'ai eu un ou deux retour me disant que le mails étais bizar. le boudary en réalité est afficher dans le mail et contient à la place de la pièce jointe :
maintenant ca n'arrive que chez une ou deux personne tous les autres le reçoivent comme il faut.Cordialement. --------------Boundary-00=_dbe87800000000000000 Content-Type: application/pdf; name="Namur-13-06-2013.pdf" Content-Disposition: attachment Content-Transfer-Encoding: base64 JVBERi0xLjcKMyAwIG9iago8PC9UeXBlIC9QYWdlIC9QYXJlbnQgMSAwIFIgL01lZGlhQm94IFsw IDAgNTk1LjI4IDg0MS44OV0gL0dyb3VwIDw8IC9UeXBlIC9Hcm91cCAvUyAvVHJhbnNwYXJlbmN5 IC9DUyAvRGV2aWNlUkdCID4+IC9SZXNvdXJjZXMgMiAwIFIKL0NvbnRlbnRzIDQgMCBSPj4gZW5k b2JqCjQgMCBvYmoKPDwvRmlsdGVyIC9GbGF0ZURlY29kZSAvTGVuZ3RoIDgxMTM+PiBzdHJlYW0K eJztnVtz20a2hd/9K/B2ZqocCo2+P9rO5YwrSWUmKuchkwfGQmzmUKRDifEkvzj+F6ebQINgLy7J Nxkt1tRMlLTRkHfvDfT6ADQW6pm21euqqZ5WdfVr9eNP4V8X4Z+vKjGr67p68eDxeXX2pahEHdrV +S/VF+cP6vfbKW46f522+f2mbK9339KMt9Qzb3Q1/rk51u19/tJ61oT/Tj9N+Hn0V/+321t3+7jH wX+3wAHrpazGP48m/r/d3q/b9AUueUvJlTuBbtMXuOQtJVfuBLpNX+CSt5RcuRPoNn2BS95ScuVO oNv0BS55S8mVO4Fu0xe45C0lV+4Euk1f4JK3lFy5E+g2fYFL3lJy5U6g2/QFLnlLyZU7gW7TF7jk LSVX7gS6TV/gkreUXLkT6DZ9gUveUnLlTqDb9AUueUvJlTuBbtMXuOQtJVfuBLpNX+CSt5RcuRPo Nn2BS95ScuVOoNv0BS55S8mVO4Fu0xe45C0lV+4Euk1f4JK3lFy5E+g2fYFL3lJy5U6g2/QFLnlL yZU7gW7TF7jkLSVX7gS6TV/gkre...... etc...
Je pense pour un problème avec leur boite mail puisque les autre le reçoive nickel, mais sait-on jamais que mon boundary soit le problème. mais je penche pour une restriction dans leurs boite mail pour les mail html/multipart avec pièce jointe.
Quand pensez-vous ?
Bonjour à tous,
Je viens faire un petit up et vous fournir le formation de mon header, car le problème semble venir de là, venant d'une classe je vous fourni la seule fonction qui génère du header.
Pour infos le fichiers est encodé en utf-8 et les données aussi
Code PHP : 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146 <?php //************************************************************************** // Entêtes (Headers) //************************************************************************** public function headers(){ // Id unique $Boundary1 = '------------Boundary-00=_'.substr(md5(uniqid(time())), 0, 7).'0000000000000'; $Boundary2 = '------------Boundary-00=_'.substr(md5(uniqid(time())), 0, 7).'0000000000000'; $Boundary3 = '------------Boundary-00=_'.substr(md5(uniqid(time())), 0, 7).'0000000000000'; $header = ''; $No_body = 0; // Adresse de l'expéditeur (format : Nom <adresse_mail>) if(!empty($this->From)){ $header .= 'X-Sender: '.$this->From."\n";// Adresse réelle de l'expéditeur } // La version mime if(!empty($this->MIME)){ $header .= 'MIME-Version: '.$this->MIME."\n"; } $header .= sprintf("Message-ID: <%s@%s>%s", md5(uniqid(time())), $this->NomDuDomaine, "\n") .'Date: '.date('r')."\n" .'Content-Type: Multipart/Mixed;'."\n" .' boundary="'.$Boundary1.'"'."\n" // Logiciel utilisé pour l' envoi des mails .'X-Mailer: PHP '.phpversion()."\n"; // Adresse de l'expéditeur (format : Nom <adresse_mail>) if(!empty($this->From)){ if(!empty($this->FromName)){ $header .= 'From: "'.$this->FromName.'"'; }else{ $header .= 'From: '; } $header .= '<'.$this->From.">\n"; } $header .= 'X-FID: FLAVOR00-NONE-0000-0000-000000000000'."\n"; // Priorité accordée au mail (valeur allant de 1 pour Urgent à 3 pour normal et 6 pour bas) if(!empty($this->Priority)){ $header .= 'X-Priority: '.$this->Priority."\n"; } // To if(!empty($this->To)){// A $header .= 'To: '.$this->To."\n"; }else{ $No_body++;// Personne } // Cc if(!empty($this->Cc)){// Copie du mail $header .= 'Cc: '.$this->Cc."\n"; }else{ $No_body++;// Personne } // Bcc if(empty($this->Bcc)){// Blind Carbon Copy, c' est à dire que les adresses qui sont contenue ici seront invisibles pour tout le monde $No_body++;// Personne } // Sujet if(!empty($this->Sujet)){ $header .= 'Subject: '.$this->Sujet."\n"; } if(!empty($this->Confimation_reception)){// Adresse utilisée pour la réponse au mail $header .= 'Disposition-Notification-To: <'.$this->Confimation_reception.'>'."\n"; } // ReplyTo if(!empty($this->ReplyTo) && $this->ReplyTo !== $this->From && $this->ReplyTo !== 'root@localhost'){// Adresse utilisée pour la réponse au mail $header .= 'Reply-to: '.$this->ReplyTo."\n" .'Return-Path: <'.$this->ReplyTo.">\n"; } if(!IsSet($_SERVER['REMOTE_ADDR'])){$_SERVER['REMOTE_ADDR'] = '127.0.0.1';} if(!IsSet($_SERVER['HTTP_X_FORWARDED_FOR'])){$_SERVER['HTTP_X_FORWARDED_FOR'] = '';} if(!IsSet($_SERVER['HTTP_USER_AGENT'])){$_SERVER['HTTP_USER_AGENT'] = 'Internet Explorer';} if(!IsSet($_SERVER['HTTP_ACCEPT_LANGUAGE'])){$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'Fr-fr';} $host = 'localhost'; if(function_exists('gethostbyaddr') && $_SERVER['REMOTE_ADDR'] !== '127.0.0.1'){$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);} $header .= 'X-Client-IP: '.$_SERVER['REMOTE_ADDR']."\n" .'X-Client-PROXY: '.$_SERVER['HTTP_X_FORWARDED_FOR']."\n" .'X-Client-Agent: '.$_SERVER['HTTP_USER_AGENT']."\n" .'X-Client-Host: '.$host."\n" .'X-Client-Language: '.$_SERVER['HTTP_ACCEPT_LANGUAGE']."\n" .'Organization: '.$this->org."\n" ."\n\n\n" .'--'.$Boundary1."\n" .'Content-Type: Multipart/Alternative;'."\n" .' boundary="'.$Boundary3.'"'."\n" ."\n\n" .'--'.$Boundary3."\n"; if($this->ContentType === 'txt' || $this->ContentType === 'txt/html'){ $header .= 'Content-Type: Text/Plain;'."\r\n" .' charset="'.$this->ISO.'"'."\r\n" .'Content-Transfer-Encoding: '.$this->Encoding."\r\n" ."\r\n"; if($this->ContentType === 'txt'){ $header .= $this->Body."\r\n"; }else{ $header .= $this->Body_txt."\r\n"; } }elseif($this->ContentType === 'html' || $this->ContentType === 'txt/html'){ if($this->ContentType === 'txt/html'){ $header .= '--'.$Boundary3."\r\n"; } $header .= 'Content-Type: Text/HTML;'."\r\n" .' charset="'.$this->ISO.'"'."\r\n" .'Content-Transfer-Encoding: '.$this->Encoding."\r\n" ."\r\n" .'<html><head>'."\r\n" .'<meta http-equiv="Content-LANGUAGE" content="French" />'."\r\n" .'<meta http-equiv="Content-Type" content="text/html; charset='.$this->ISO.'" />'."\r\n" .'</head>'."\r\n" .'<body>'."\r\n" .$this->Body."\r\n" .'</body></html>'."\r\n" .'--'.$Boundary3.'--'."\r\n"; }else{ $header .= 'Content-Type: '.$this->ContentType.';'."\r\n" .' charset="'.$this->ISO.'"'."\r\n" .'Content-Transfer-Encoding: '.$this->Encoding."\r\n" ."\r\n" .$this->Body."\r\n"; } $header .= "\n"; // On joint le ou les fichiers if($this->File_joint){ foreach($this->File_joint as $file_name => $file){ $header .= '--'.$Boundary1."\n" .'Content-Type: '.$file['mime'].';'."\n" .' name="'.$file_name.'"'."\n" .'Content-Disposition: attachment'."\n" .'Content-Transfer-Encoding: BASE64'."\r\n" ."\n" .chunk_split(base64_encode(file_get_contents($file['url'])))."\n" ."\n\n"; } } $header .= '--'.$Boundary1.'--'; if($No_body === 3){ $this->erreur = 'Le mail n' a pas de destinataire !!!'; return false; } return $header; } ?>
Merci d'avance de votre aide
Partager