bonsoir !

objectif réussir a envoyer un email xhtml + pj OU texte normal + pj

voici une page test:

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
 
<?php
 
 
//=====Déclaration des messages au format texte et au format HTML
	 // message : 
	$message_html = 
 
	"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">"."\n".
	"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">"."\n".
 
	"<head>"."\n".
	"<title>Mail</title>"."\n".
 
	"<style type=\"text/css\">
	<!--	
	

body {
	font-family: Verdana, sans-serif;
	background-image: url(<a href="http://site.fr/background.gif);" target="_blank">http://site.fr/background.gif);</a>
}
 
/* Images */
img { 
	border: 0px;
}
 
table
{
	border-collapse:collapse;
}
 
/* Aucun espacement */
table td
{
	padding:0px;
}
 
td.header_mail {
	background-image: url(<a href="http://site.fr/poo/header.jpg" target="_blank">http://site.fr/poo/header.jpg</a>) ;
	width: 600px;
	height: 107px;
}
 
td.texte_mail {
	font-family: Verdana, sans-serif;
	background-color: rgb(17,31,39);
	font-size: 10pt;
	font-weight: bold;
	color: rgb(204,235,245);
	width: 600px;
}
 
td.texte_mail a:hover {
color: #FDFF00;
text-decoration: none;
}
 
td.texte_mail a:active, td.texte_mail a:visited, td.texte_mail a:link {
color: #FFA200;
text-decoration: none;
}
 
td.footer_mail {
	background-image: url(<a href="http://site.fr/footer.jpg" target="_blank">http://site.fr/footer.jpg</a>) ;
	width: 600px;
	height: 24px;
}
 
	-->
	</style>"."\n".
	
	"</head>"."\n".
	"<body>"."\n".
		"<div align=\"center\">"."\n".
			"<table>"."\n".
			"<tr>"."\n".
			"<td class=\"header_mail\"></td>"."\n".
			"</tr>"."\n".
			"<tr>"."\n".
			"<td class=\"texte_mail\">__________<em>TEST</em>___________<br />&nbsp;</td>"."\n".
			"</tr>"."\n".
			"<tr>"."\n".
			"<td class=\"footer_mail\"></td>"."\n".
			"</tr>"."\n".
			"</table>"."\n".
		"</div>"."\n".
	"</body>"."\n".
"</html>"."\n";
//==========
 
 
//=====Lecture et mise en forme de la pièce jointe
$fichier   = fopen("777.gif", "r");
$attachement = fread($fichier, filesize("777.gif"));
$attachement = chunk_split(base64_encode($attachement));
fclose($fichier);
//==========
 
//=====Création de la boundary
$boundary = "-----=".md5(rand());
$boundary_alt = "-----=".md5(rand());
//==========
 
//=====Définition du sujet
$sujet = "Hey mon ami !";
//=========
 
//=====Création du header de l'e-mail
$header = "From: \"WeaponsB\"<mail@yahoo.fr>\n";
$header.= "Reply-to: \"WeaponsB\" <mail@yahoo.fr>\n";
$header.= "MIME-Version: 1.0\n";
$header.= "Content-Type: multipart/mixed;\n boundary=\"$boundary\"\n";
//==========
 
//=====Création du message
$message = "\n--".$boundary."\n";
$message.= "Content-Type: multipart/alternative;\n boundary=\"$boundary_alt\"\n";
$message.= "\n--".$boundary_alt."\n";
 
//=====Ajout du message au format texte
$message.="Content-Type: text/plain; charset=\"ISO-8859-1\"\n";
$message.="Content-Transfer-Encoding: 8bit\n";
$message.= $message_txt."\n";
//==========
 
$message.= "\n--".$boundary_alt."\n";
 
//=====Ajout du message au format HTML
$message.="Content-Type: text/html; charset=\"ISO-8859-1\"\n";
$message.="Content-Transfer-Encoding: 8bit\n";
$message.= $message_html."\n";
//==========
 
//=====On ferme la boundary alternative
$message.= "\n--".$boundary_alt."--\n";
//==========
 
 
$message.= "\n--".$boundary."\n";
 
//=====Ajout de la pièce jointe
$message.= "Content-Type: application/pdf;\n name=\"777.gif\"\n";
$message.= "Content-Transfer-Encoding: base64\n";
$message.= "Content-Disposition: attachment;\n filename=\"777.gif\"\n";
$message.= "\n".$attachement."\n\n";
$message.= "\n--".$boundary."--\n"; 
//========== 
//=====Envoi de l'e-mail
mail("mail@yahoo.fr",$sujet,$message,$header);
echo "ok";
 
//==========
?>

voici le résultat:

je reçois bien la pièce jointe mais mon texte en xhtml n'est pas du tout correcte que faire
exemple d'affichage :
http://ups.imagup.com/04/1244580027_prob.jpg