Bonjour a tous

Je dois envoyer en pièce jointe une image jpeg avec du texte brut.
Pour créer ma fonction je me suis basé sur les exemples du livre PHP5 avancé 2e édition.

Voici le script:
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
function sendMailMulti($to, $sujet, $message){
      $delim = md5 ( mt_rand () );
      // entête du mail
      $entete = "MIME-Version: 1.0\n";
      $entete.= "From: info@monsite.fr\n";
      $entete.= "Reply-to: noreply@monsite.fr\n";
      $entete.= "Content-Type: multipart/mixed; boundary=\"$delim\"\n";
      $entete.= "\n";
      // début du message
      $frontiere = "- -$delim\n";
      $frontiere.= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
      $frontiere.= "Content-Transfert-Encoding:8bit\n";
      $frontiere.= "\n";
      $frontiere.= $message."\n";
      $frontiere.= "\n";
      // fichier joint
      $attacher = file_get_contents ( "./photos/maphoto.jpg" );
      $attacher = chunk_split ( base64_encode ( $attacher ) );
      $fichier.= "- -$delim\n";
      $fichier.= "Content-Type: image/jpeg; name=\"maphoto.jpg\"\n";
      $fichier.= "Content-Transfert-Encoding: base64\n";
      $fichier.= "Content-Disposition: attachment; filename=\"./photos/maphoto.jpg\"\n";
      $fichier.= " \n";
      $fichier.= $attacher."\n";
      $fichier.= "\n";
      $fichier.= "- -$delim- -";
      $finalMessage = $noMime.$frontiere.$fichier;
      $envoi = mail ( $to, $sujet, $finalMessage, $entete );
}

Le probleme est que je recois le message sous forme de texte complet,
l'image en base64 et meme les entetes sont dans le corp du message
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
 
- -439d44241c88fda0723ac4697eb99440
Content-Type: text/plain; charset="iso-8859-1" Content-Transfert-Encoding:8bit
 
Blabla...
 
- -439d44241c88fda0723ac4697eb99440
Content-Type: image/jpeg; name="maphoto.jpg"
Content-Transfert-Encoding: base64
Content-Disposition: attachment; filename="./photos/maphoto.jpg"
 
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIf
 
IiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7
IiEmKzcvJik0KSEiMEExNDk7Pj4+Ozs7
 
Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Oz ... etc
 
- -439d44241c88fda0723ac4697eb99440
Je sais que vous allez dire "utilise phpmailer patati et patata mais avant d'utiliser ces classes j'aimerais bien comprendre le pourquoi du comment

Alors, une idée