Bonjour,
pour une association du jura, je m'occupe de leur site.
Un formulaire permet de poser d'envoyer ses coordonnées, de mettre un commentaire et d'envoyer une pièce jointe traitement de texte, tableur ou pdf (contrôler au moment de l'upload).
Mon problème est d'envoyer à la personne qui va gérer les réponses les données de l'expéditeur(çà, je sais faire) mais également la pièce jointe qui se trouve dans un dossier "fichier" .
J'ai essayé pas mal de tutos mais au mieux je récupère une pièce jointe vide
voilà mon code sans l'insertion de cette pièce , il peut au moins servir pour quelqu'un qui ne gère pas les PJ:
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
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
147
148
149
150
  <?php
$date = date("d-m-Y");
$img_nom = $_POST['img_nom'];    
$civilite = $_POST['civilite'];
$prenom = $_POST['prenom'];
$nom = $_POST['nom'];
$adresse = $_POST['adresse'];
$ville = $_POST['ville'];
$cp = $_POST['cp'];                
$telfix = $_POST['telfix'];
$mobile = $_POST['mobile'];      
$email = $_POST['email'];
$site = $_POST['site'];      
$titre = $_POST['titre']; 
$texte = $_POST['texte']; 
$datannonce = $_POST['datannonce'];    
 
// Préparation du mail contenant la réponse
$destinataire = "comefor39@orange.fr";
$comefor39 = $email;
$Page = "contact mail";
$from_email = "$comefor39";
$to_email = "$destinataire ";
$path = "apports/logomail.png";
$fichier = basename($path);
$subject_date = date("d-m-Y H:i");
$subject = "Votre contact avec EFOR9-FC le " . $subject_date;
$boundary = "-----=" . md5( uniqid ( rand() ) );
$headers = "From: $from_emailn";
$headers .= "MIME-Version: 1.0n";
$headers .= 'Content-Type: multipart/mixed;boundary='.$boundary."\r\n";          
$message = "Ceci est un message au format MIME 1.0 multipart/mixed.nn";
$message .= "--" . $boundary . "n";
 //=====Lecture et mise en forme de la pièce jointe.
$path = $_SERVER['DOCUMENT_ROOT']."/fichier";  
$typepiecejointe = filetype($path.$img_nom);  
$data = chunk_split( base64_encode(file_get_contents($path.$img_nom)) );  
//==========
// Début section html
$message .= 'Content-type: text/html; charset=iso-8859-1'."\r\n\r\n";     
$message .= "Content-Transfer-Encoding: quoted-printablen";
$message .= "n";
$message .= "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
$message .= "<HTML><BODY>n";
 
// on génère une frontière
$boundary = "-----=" . md5( uniqid ( rand() ) );
$headers ='From: "EFOR39-FC"<comefor39@orange.fr>' . "\n";   
$headers .= 'Content-Type: multipart/mixed;boundary='.$boundary."\r\n";          
$message = "Ceci est un message au format MIME 1.0 multipart/mixed.nn";
$message .= "--" . $boundary . "n";
 
// Début section html
$message .= 'Content-type: text/html; charset=iso-8859-1'."\r\n\r\n";     
$message .= "Content-Transfer-Encoding: quoted-printablen";
$message .= "n";
$message .= "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
# Message envoyé au visiteur         
$headers ='From: "EFOR39-FC"<comefor39@orange.fr>' . "\n";     
$headers .='MIME-Version: 1.0' . "\n";
$headers .='Content-Type: text/html; charset="iso-8859-1"' . "\n";
$headers .='Content-Transfer-Encoding: 8bit'; 
$message = "<html><head><title>email de contact</title>
</head>";
$message .= "<body>
<STYLE type=text/css>
<!--
body
{
background: #f0b7a1; /* Old browsers */
background: -moz-linear-gradient(top,  #f0b7a1 0%, #8c3310 32%, #752201 70%, #bf6e4e 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f0b7a1), color-stop(32%,#8c3310), color-stop(70%,#752201), color-stop(100%,#bf6e4e)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #f0b7a1 0%,#8c3310 32%,#752201 70%,#bf6e4e 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #f0b7a1 0%,#8c3310 32%,#752201 70%,#bf6e4e 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #f0b7a1 0%,#8c3310 32%,#752201 70%,#bf6e4e 100%); /* IE10+ */
background: linear-gradient(to bottom,  #f0b7a1 0%,#8c3310 32%,#752201 70%,#bf6e4e 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f0b7a1', endColorstr='#bf6e4e',GradientType=0 ); /* IE6-9 */


}
.tableau 
{
margin-top:25px;
border:ridge 5px #cdab88;
-moz-border-radius: 24px;
-webkit-border-radius: 24px;
border-radius: 24px;
width: 500px;
margin-left:auto;
margin-right:auto;
padding:5px;
background-color: rgba(145, 141, 199, 0.7);
background: rgba(145, 141, 199, 0.7);
color: rgba(145, 141, 199, 0.7);
color:white;
font-weight:bolder;
text-shadow:5px 5px 5px #e86da9;
}
.texte
{
width:auto;
background-color: rgba(232, 227, 217, 0.9);
background: rgba(232, 227, 217, 0.9);
color: rgba(232, 227, 217, 0.9);
color:#bf6d56;
text-shadow:5px 5px 5px #d9ced9;
border:outset 3px #9d9be0;
-moz-border-radius: 23px;
-webkit-border-radius: 23px;
border-radius: 23px;
}
-->
</STYLE>
            <table  class=\"tableau\">
                <tr>
                        <td colspan=\"3\" style=\"text-align:center;color:#000;background:#FFF\" >réception<br \">de mail avec le formulaire du site</td>
                </tr> 
                <tr>
                    <td rowspan=\"5\" style=\"text-align:center;color:#000;background:##ecefd3\"><img src=\"http://www.efor39.fr/apports/logomail.png\" /><br />
                        reçu le ".$date." 
                    </td>
                     <td style=\"text-align:left\">Coordonnées</td>
                     <td  class=\"texte\"> ".$_POST['civilite']."  ".$_POST['prenom']." ".$_POST['nom']." </td> 
                </tr>
                <tr>
                    <td style=\"text-align:left\">Adresse</td> 
                     <td  class=\"texte\"> ".$_POST['adresse']."<br />
                     ".$_POST['cp']."".$_POST['ville']."</td>
                </tr>
                <tr>
                    <td style=\"text-align:left\">Adresses électroniques</td>
                     <td  class=\"texte\">email : ".$_POST['email']."<br />
                     site:".$_POST['site']."</td>
                </tr>
                <tr>   
                     <td style=\"text-align:center\">texte joint </td>
                     <td  class=\"texte\"> ".$_POST['texte']."</td>
                </tr>
                <tr>             
                        <td>si pièce jointe, son titre, </td>
                        <td  class=\"texte\">".$_POST['titre']."</td>
                </tr>
                <tr>
                        <td colspan=\"3\"><img src=\"http://www.sitadom39.fr/apports/basmail.png\" /></td>
                </tr> 
            </table>;
</body>
</html>";
mail($to_email,$subject, $message, $headers);
?>
Merci d'avance si vous pouvez me donner un conseil.
DM