Salut tout le monde je veux envoyer un email avec une image le code pour l'envoi du texte ca marche mais lorsque j'ai ajouté le code pour l'envoi de l'image j'ai un problème

voila le code
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
 
 
 
 
<?php
	include('functions.php');
	include ("class.php");
 
 
	if($_POST['type']=="HTML"){
 
	if($_POST['t1']!=""){
		$to=$_POST['t1'];
		$subject=$_POST['t2'];
		$message=$_POST['text'];
 
 
 
 
 
		if (mailer("gousalah@gmail.com","Test Salah","gousalah@gmail.com",$to,$subject,$message))$cas=true;
 
	if($cas){
 
			echo"<script language='javascript'>document.location.replace('conf.php');</script>";
		}
	}
 
 
 
 
		if($_POST['t1']==""){
$fl=$_POST['file'];
$fp = fopen ($fl, "r");  
$contenu_du_fichier = fgets ($fp, 255); 
 $boundary = md5(uniqid(microtime(), TRUE));
		$subject=$_POST['t2'];
		$message=$_POST['text']; 
		$message.= '--'.$boundary."\r\n";
 $to=$contenu_du_fichier;
 
fclose ($fp); 
 
 
//piece jointe
$file_name = $_POST['piece'];
if (file_exists($file_name))
{
 
 
$file_type = filetype($file_name);
$file_size = filesize($file_name);
$handle = fopen($file_name, 'r') or die('File '.$file_name.'Impossible');
$content = fread($handle, $file_size);
$content = chunk_split(base64_encode($content));
$f = fclose($handle);
 
 
$message .= 'Content-type:'.$file_type.';name='.$file_name."\r\n";
	$message.= '--'.$boundary."\r\n";
 
 
$message .= $content."\r\n";
 
}	
 
		if (mailer("gousalah@gmail.com","Test Salah","gousalah@gmail.com",$to,$subject,$message))$cas=true;
 
	if($cas){
 
			echo"<script language='javascript'>document.location.replace('conf.php');</script>";
		}
	}
 
 
	}
 
 
 
	else
	{
 
 
 
	if($_POST['t1']!=""){
		$to=$_POST['t1'];
		$subject=$_POST['t2'];
		$message=$_POST['text'];
 
 
 
 
		if (mailer2("gousalah@gmail.com","Test Salah","gousalah@gmail.com",$to,$subject,$message))$cas=true;
 
	if($cas){
 
			echo"<script language='javascript'>document.location.replace('conf.php');</script>";
		}
	}
 
 
 
 
		if($_POST['file']!=""){
$fl=$_POST['file'];
$fp = fopen ($fl, "r");  
$contenu_du_fichier = fgets ($fp, 255); 
		$subject=$_POST['t2'];
		$message=$_POST['text']; 
 $to=$contenu_du_fichier;
fclose ($fp); 
 
		if (mailer2("gousalah@gmail.com","Test Salah","gousalah@gmail.com",$to,$subject,$message))$cas=true;
 
	if($cas){
 
			echo"<script language='javascript'>document.location.replace('conf.php');</script>";
		}
	}
 
 
 
 
 
 
 
 
	}
 
 
?>
 
 
 
 
<script language="javascript" src="functions.js"></script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<?php /*?><script type="text/javascript" src="editeur/tiny_mce.js"></script>
<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
 
		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect",
		theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,image,cleanup,insertdate,inserttime,preview,|,forecolor,backcolor,fontsizeselect",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,",
		theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,visualchars,|,sub,sup,|,charmap,emotions,|,ltr,rtl,|,fullscreen",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
 
		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",
 
		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",
 
		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
</script><?php */?>
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans nom</title>
</head>
 
<body >
   <form id="f1" name="f1" method="post" action="index.php">
<table>
<tr><td>Type :<td><select name="type">
<option>HTML</option>
<option>TEXT</option>
</select>
<tr><td>To :<td><input type="text" name="t1" />
<tr><td>Parcourir votre liste :<td><input type="file" name="file" />
 
<tr><td>Sujet :<td><input type="text" name="t2" />
<tr><td>Votre text:<td><textarea cols="40" rows="10" name="text"></textarea>
<tr><td>Piece jointe :<td><input type="file" name="piece" />
       <input name="operation" type="hidden" id="operation" value="mailing" />
<tr><td><input type="button" value="Envoyer" onClick="mail()" />
</table>
</form>
</body>
</html>
je fé appele aussi a cette page
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
function mailer($from,$fromname,$replayto,$to,$subject,$message,$charset="iso-8859-1",$type=" image/jpeg"){
 
 
	$header="Date: ".date("D, j M Y G:i:s")." +0700\n";
	$header.="From: $fromname<$from>\n";
	$header.="Reply-To: <$replayto>\n";
	  $header.= 'MIME-Version: 1.0'."\n";
 
	$header.="Content-Type:multipart/mixed;charset=$charset\r\n";
	 $header.= 'Content-transfer-encoding:base64'."\r\n\r\n";
return(mail($to,$subject,$message,$header));
}
l'email reçu est celui la
Code : Sélectionner tout - Visualiser dans une fenêtre à part
®ºë®ºësõÕ·á¦›Ù*ÚuÝ8Ùý[á¯zuöœ‰íz{mÊ—ŸŠW§jg¢™¨Ž˜ç}umçxi¦ökvwN6Vøkޝ}§?ö?ø