Page 1 sur 1

reception du mail en html

Posté : 28 déc. 2005, 13:46
par dam-s
Slt une autre question,
<?php require_once('../phpconnexion.php'); ?>
<?php
session_start();
$MM_authorizedUsers = "administrateur,operateur";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../public/loginpublic_inc.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
mysql_select_db($database_phpconnexion, $phpconnexion);
$query_rsselectmail = "SELECT email FROM chds_utilisateurs WHERE email != ''";
$rsselectmail = mysql_query($query_rsselectmail, $phpconnexion) or die(mysql_error());
$row_rsselectmail = mysql_fetch_assoc($rsselectmail);
$totalRows_rsselectmail = mysql_num_rows($rsselectmail);
?>
<?php
//$MailTo = "vous@nom_domaine.com"; //adresse à laquelle sera envoyé le contenu du formulaire
$MailSubject = "mise à jour du site CHDS"; //texte qui va figurer dans le champ "sujet" du email
$MailHeader = "From: [email protected]\n"; //adresse email qui va figurer dans le champ "expéditeur" du email et qui peut être remplacé par la variable "$champx" ("$champ3").
$MailHeader .= "Reply-To: [email protected]\n";

$MailBody='
<!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>
<link href="http://76chds.free.fr/Templates/chds/chds.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" >
<tr>
<td width="0%">
<p><img src="http://76chds.free.fr/Templates/chds/images/entete_ajout.gif" width="150" height="38" border="0"></p>
</td>
<td width="100%" background="http://76chds.free.fr/Templates/chds/images/bar_c.gif">
</td>
<td width="0%">
<p><img src="http://76chds.free.fr/Templates/chds/images/bar_d.gif" width="42" height="38" border="0"></p>
</td>
</tr>
</table>

	<table class="forumline" width="100%" cellspacing="0" cellpadding="0" border="0" >
	<tr>
	<td align="left" valign="top" class="row3"><p>
		<table width="100%"  border="0" align="" cellpadding="0" cellspacing="0" >
              <tr height="2"></tr>
               <tr>
                <th width="100%" height="20" class="thhead" colspan="2"><div >
                  <div align="center">..:: Message de Mise à jours ::..</div>
                </div></th>
                </tr>				
<tr height="10"><td></td></tr>
<tr><td>Le site du C.H.D.S. a été mis à jours... veuillez vous rendre à l&acute;adresse suivante: <a href="http://76chds.free.fr/">76chds.free.fr</a>

';
/* Les routines suivantes permettent à chacune des variables de prendre la valeur des champs du formulaire et de les stocker ensuite dans la variable globale MailBody qui constituera le corps du message */

//Routine pour les cases à cocher
if ($champ6 != ""){
$MailBody .= "Commentaires : $champ6\n\n";

}

$MailBody .="Sections modifiées : \n";

$items = 16; //initialisation du nombre d'items possibles

for ($i = 1; $i <= $items; $i++) { //boucle sur le nombre d'items

$MailBody .= "$champ8[$i] \n"; //stockage des items choisis dans la variable MailBody

}
$MailBody.='
</td></tr>
<tr height="10"><td></td></tr>
		  <tr>
             <td height="4" class="spacerow"><div align="center"><img src="http://76chds.free.fr/Templates/chds/images/spacer.gif" alt="" width="1" height="1"></div></td>
          </tr>
<tr height="2"><td class="row3"></td></tr>
</table></table>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="70%">
<p><img src="http://76chds.free.fr/Templates/chds/images/bar_f_g.gif" width="100%" height="24" border="0"></p>
</td>
<td width="30%" background="http://76chds.free.fr/Templates/chds/images/bar_f_c.gif">
</td>
<td width="0%">
<p><img src="http://76chds.free.fr/Templates/chds/images/bar_f_d.gif" width="100%" height="24" border="0"></p>
</td>
</tr>
</table>
</body>
</html>
';

//Envoi du message

$msg_body = stripslashes($MailBody);
 
   while ($row_rsselectmail = mysql_fetch_assoc($rsselectmail))
   {
        $mail=$row_rsselectmail['email'];
 mail($mail, stripslashes($MailSubject), $msg_body, $MailHeader); //envoi du message
    }
?>
<?php
include ('../includes/page_header_privee.php');
?>
<table border="0" cellpadding="0" cellspacing="0" width="75%" align="center"><tr><td>

<table border="0" cellpadding="0" cellspacing="0" width="100%" >
<tr>
<td width="0%">
<p><img src="../Templates/chds/images/entete_mailling.gif" width="150" height="38" border="0"></p>
</td>
<td width="100%" background="../Templates/chds/images/bar_c.gif">
</td>
<td width="0%">
<p><img src="../Templates/chds/images/bar_d.gif" width="42" height="38" border="0"></p>
</td>
</tr>
</table>
	<table class="forumline" width="100%" cellspacing="0" cellpadding="0" border="0" >
	<tr>
	<td align="left" valign="top" class="row3"><p>
		<table width="100%"  border="0" align="" cellpadding="0" cellspacing="0" >
              <tr height="2"></tr>
               <tr>
                <th width="100%" height="20" class="thhead" colspan="3"><div >
                  <div align="center">Mail envoyé</div>
                </div></th>
                </tr>
  <tr height="10"><td></td></tr>

<tr><td>
<table align="center" width="80%"><tr><td align="center">
<?php	echo "$MailBody";?>
</td></tr></table>
</td></tr>
  <tr height="10"><td></td></tr>
</table> 
		  <tr>
                  <td height="4" colspan="4" class="spacerow"><div align="center"><img src="../Templates/chds/images/spacer.gif" alt="" width="1" height="1"></div></td>
              </tr>
			   <tr height="2"><td class="row3"></td></tr>
	 </tr>
</table>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="70%">
<p><img src="../Templates/chds/images/bar_f_g.gif" width="100%" height="24" border="0"></p>
</td>
<td width="30%" background="../Templates/chds/images/bar_f_c.gif">
</td>
<td width="0%">
<p><img src="../Templates/chds/images/bar_f_d.gif" width="100%" height="24" border="0"></p>
</td>
</tr>
</table>
</table>
<?php
mysql_free_result($rsselectmail);
?>
quant j'envoie le mail je recoit un mail mais il esten code et non en html comme je le voudrai,
j'ai que du code dans le mail
quelqu'un sais pourquoi ???

Dam-s

Posté : 28 déc. 2005, 14:17
par Cyrano
Tu n'avais pas besoin d'en coller une telle tartine, enfin bon: il manque deux éléments dans les en-têtes que tu envoies : ajoute ceci
$MailHeader .= 'MIME-Version: 1.0' . "\r\n";
$MailHeader .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

Posté : 28 déc. 2005, 14:27
par dam-s
merci lol

Posté : 18 janv. 2006, 12:38
par Invité
J'ai exactement le meme probleme que dam-s et meme avec les reponses que vous avez données les mails que j'envois s'affiche toujours en code. Voici mon code, peut etre est-ce moi qui n'arrives pas a voir mon erreur:
<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php

include("templates/dbconnect.php");

$sql = 'Select MAIL From client where MAIL is not null';
$req = MySQL_Query ($sql)or die(mysql_error());

$donnée_html = file_get_contents('top.html'); 

while ($data = mysql_fetch_assoc($req)) 
    { 
$sql3= "SELECT titre FROM newsletter_envoi ORDER BY id desc LIMIT 1"; 
    $req3=mysql_query($sql3) or die(mysql_error()); 
    $info=mysql_fetch_array($req3); 
	
	$to = $data['MAIL']; 
	$subject = $info['titre'];
	$headers  = 'MIME-Version: 1.0 ' . "\r\n"; 
    $headers .= 'From: [email protected] \n';
    $headers .= 'Return-Path: Webmaster <[email protected]>\n';
	$headers .= 'Content-Type: text/html; charset=iso-8859-1' . "\r\n"; 
    $headers .= 'Reply-To: Webmaster <[email protected]> \n';
$ok = mail($data['MAIL'], $subject, $donnée_html, $headers); 
if ($ok) 
 {
 echo "Envoi réussi du message à $to !<br>"; 
 }
else 
{
 echo "L'envoi a échoué ..<br>"; 
 }
} 
mysql_close();
?>
</html>
merci d'avance et si besoin est, je peux vous fournir le code de ma page top.html.