begin process at 2012 05 31 12:53:39
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive PHP

 > 

Archives

 > 

Divers

 > 

Probleme d'envoi de mail html


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Probleme d'envoi de mail html

dimanche 23 octobre 2005 à 12:42:39 | Probleme d'envoi de mail html

fanfouer

Membre Club

Bonjour,
Je travaille sur un script qui m'envoie un mail tous les jours a minuit pour me transmettre un listing sur la journée qui vien de s'écouler.
Le probleme c'est que je veu que le mail soit en html (pour qu'il ai la meme aparance que mon site) mais il n'aparait pas en htmlet reste sous le format texte standart.

Comment faire pour qu'il aparaisse comme je le soushaite?

Mon code :
<?
mysql_connect ("localhost", "xxxxxxxxxx", "xxxxxxxxxxxxxxxxx"); //connexion a MySQL
mysql_select_db("xxxxxxxxxxxxxxxx"); // Sélection de la base xxxxxxx
//la base "xxxx" est connecté, on peut travailler dessus
verifUser ("administrateur", "administrateur");
//déclaration fonction
//requete SQL type pour afficher des donnees dans les colonnes
function sql_query ($FAI){
 if($FAI!=""){
  $reponse = mysql_query("SELECT * FROM dslam_none WHERE FAI='$FAI'");
 }
 return $reponse;
}
function affichageListeDSLAMnone ($reponse){
 while ($elementListe = mysql_fetch_array($reponse)){
 echo'<tr class='.listeDSLAM_bgColor($i, $elementListe['etat']).'>
  <td class="tableau3">
  <a href=index.php?page=caracs1&dslam='.$elementListe['dslam'].'&FAI='.$elementListe['FAI'].'>'.$elementListe['dslam'].'</a>
  </td>
  <td class="tableau3">
  <a href=index.php?page=dslam&vue='.$elementListe['RE'].'&FAI='.$elementListe['FAI'].'>'.$elementListe['RE'].'</a>
  </td>
  <td class="tableau3">'.
  $elementListe['IP'].
  '</td>
  <td class="tableau3">'.
  $elementListe['Groupe'].
  '</td>
  <td class="tableau3">'.
   $elementListe['FAI'].
  '</td>
  </tr>';
  $i++;
 }
}

/* destinataire */
$to  = "Administrateur <
mail_admin@monsite.com>";

/* sujet */
$subject = "Récapitulatif des DSLAM non joignables";

/* message */
$message= '
<HTML>
<HEAD>
<TITLE>France Télécom - liste des DSLAM non joignables</TITLE>
<META HTTP-EQUIV=
"Content-Type" CONTENT="text/html; charset=iso-8859-1">
<link href="maquette.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<p align="center" class="verdana-10px-noir-strong">Liste des DSLAM totalement ou partiellement non joignable ce jour :</p>
<table width="100%" height="77" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td width="14" height="22"><img src="
http://monsite.com/images/ct_ul.jpg" width="14" height="22"></td>
    <td width="967" background="
http://monsite.com/images/ct_ubg.jpg"><div align="center"> <span class="verdana-12px-blanc">Listing Free</span> </div></td>
    <td width="14"><img src="
http://monsite.com/images/ct_ur.jpg" width="14" height="22"></td>
  </tr>
  <tr valign="top">
    <td height="36" background="
http://monsite.com/images/ct_l.jpg"><img src="http://monsite.com/images/ct_ml.jpg" width="14" height="34"></td>
    <td bgcolor="#4478B1" ><div align="center">
      <table width="100%" class="tableau1">
        <tr>
          <th width="192" height="30" class="tableau_entete">DSLAM(
                  <? count_dslam($vue, $dslam, $IP, "Free", $etat, "1"); ?>
            )</th>
          <th width="120" class="tableau_entete">RE</th>
          <th width="171" class="tableau_entete">IP</th>
          <th width="294" class="tableau_entete">Horaire</th>
          <th width="166" class="tableau_entete">FAI</th>
          <?
     $reponse = sql_query ("Free");
   affichageListeDSLAMnone ($reponse);
   ?>
        </table>
    </div></td>
    <td background="
http://monsite.com/images/ct_right.jpg"><img src="http://monsite.com/images/ct_mr.jpg" width="14" height="34"></td>
  </tr>
  <tr>
    <td background="
http://monsite.com/images/ct_bl.jpg"height="19"></td>
    <td background="
http://monsite.com/images/ct_bbg.JPG"><img src="http://monsite.com/images/ct_bbg.JPG" width="1" height="10"></td>
    <td background="
http://monsite.com/images/ct_br.jpg"></td>
  </tr>
</table>
<br>
<table width="100%" height="77" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td width="14" height="22"><img src="
http://monsite.com/images/ct_ul.jpg" width="14" height="22"></td>
    <td width="967" background="
http://monsite.com/images/ct_ubg.jpg"><div align="center"> <span class="verdana-12px-blanc">Listing Neuf</span> </div></td>
    <td width="14"><img src="
http://monsite.com/images/ct_ur.jpg" width="14" height="22"></td>
  </tr>
  <tr valign="top">
    <td height="36" background="
http://monsite.com/images/ct_l.jpg"><img src="http://monsite.com/images/ct_ml.jpg" width="14" height="34"></td>
    <td bgcolor="#4478B1" ><div align="center">
      <table width="100%" class="tableau1">
        <tr>
          <th width="192" height="30" class="tableau_entete">DSLAM(
                  <? count_dslam($vue, $dslam, $IP, "Neuf", $etat, "1"); ?>
            )</th>
          <th width="120" class="tableau_entete">RE</th>
          <th width="171" class="tableau_entete">IP</th>
          <th width="294" class="tableau_entete">Horaire</th>
          <th width="166" class="tableau_entete">FAI</th>
          <?
     $reponse = sql_query ("Neuf");
   affichageListeDSLAMnone ($reponse);
   ?>
        </table>
    </div></td>
    <td background="
http://monsite.com/images/ct_right.jpg"><img src="http://monsite.com/images/ct_mr.jpg" width="14" height="34"></td>
  </tr>
  <tr>
    <td background="
http://monsite.com/images/ct_bl.jpg"height="19"></td>
    <td background="
http://monsite.com/images/ct_bbg.JPG"><img src="http://monsite.com/images/ct_bbg.JPG" width="1" height="10"></td>
    <td background="
http://monsite.com/images/ct_br.jpg"></td>
  </tr>
</table>
<br>
<table width="100%" height="77" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td width="14" height="22"><img src="
http://monsite.com/images/ct_ul.jpg" width="14" height="22"></td>
    <td width="967" background="
http://monsite.com/images/ct_ubg.jpg"><div align="center"> <span class="verdana-12px-blanc">Listing Wanadoo</span> </div></td>
    <td width="14"><img src="
http://monsite.com/images/ct_ur.jpg" width="14" height="22"></td>
  </tr>
  <tr valign="top">
    <td height="36" background="
http://monsite.com/images/ct_l.jpg"><img src="http://monsite.com/images/ct_ml.jpg" width="14" height="34"></td>
    <td bgcolor="#4478B1" ><div align="center">
      <table width="100%" class="tableau1">
        <tr>
          <th width="192" height="30" class="tableau_entete">DSLAM(
                  <? count_dslam($vue, $dslam, $IP, "wanadoo", $etat, "1"); ?>
            )</th>
          <th width="120" class="tableau_entete">RE</th>
          <th width="171" class="tableau_entete">IP</th>
          <th width="294" class="tableau_entete">Horaire</th>
          <th width="166" class="tableau_entete">FAI</th>
          <?
     $reponse = sql_query ("wanadoo");
   affichageListeDSLAMnone ($reponse);
   ?>
        </table>
    </div></td>
    <td background="
http://monsite.com/images/ct_right.jpg"><img src="http://monsite.com/images/ct_mr.jpg" width="14" height="34"></td>
  </tr>
  <tr>
    <td background="
http://monsite.com/images/ct_bl.jpg"height="19"></td>
    <td background="
http://monsite.com/images/ct_bbg.JPG"><img src="http://monsite.com/images/ct_bbg.JPG" width="1" height="10"></td>
    <td background="
http://monsite.com/images/ct_br.jpg"></td>
  </tr>
</table>
</body>
</html>
';
/* Pour envoyer un mail au format HTML, vous pouvez configurer le type Content-type. */
$headers = "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "Content-Transfer-Encoding: quoted-printable\n";
$headers .= "Content-Disposition: inline \n\n";

/* et hop, à la poste */
mail($to, $subject, $message, $headers);
//on vide la table l'envoi terminé
mysql_query("TRUNCATE dslam_none");
?>


Voila, en espérant que cela vous inspire

dimanche 23 octobre 2005 à 14:12:13 | Re : Probleme d'envoi de mail html

monoceros01

Réponse acceptée !
$headers  = 'Content-Type: text/html; charset=iso-8859-1'."\r\n";

// Je ne connais pas les deux entêtes qui suivent, mais en tout cas il faut respecter les \r\n en fin de ligne
$headers .= 'Content-Transfer-Encoding: quoted-printable'."\r\n";
$headers .= 'Content-Disposition: inline'."\r\n";

Visiblement ce sont tes headers qui ont une mauvaise syntaxe. La moindre erreur et ton client mail ne pourra pas les interpréter.
Et je te conseil de rajouter :
$headers .= 'From: toi <tonmail@domain.com>'."\r\n";





dimanche 23 octobre 2005 à 18:54:39 | Re : Probleme d'envoi de mail html

fanfouer

Membre Club
Réponse acceptée !

Effectivement, les headers n'étaient pas bon...
je les aient donc remplacés par ca :
//headers
$from = "MIME-version: 1.0\n";
$from .= "Content-type: text/html; charset= iso-8859-1\n";

//le tout a la poste
mail($to, $subject, $corps,$from);

Merci pour ton aide

dimanche 23 octobre 2005 à 19:35:11 | Re : Probleme d'envoi de mail html

monoceros01

hmmm ok!


Cette discussion est classée dans : images, http, jpg, ct, monsite


Répondre à ce message

Sujets en rapport avec ce message

Image aléatoire ! [ par rezan16000 ] Bonjour, voila j'aurais aimé avoir une image qui apparaît aléatoirement. Cependant j'aimerais que cette image soit tiré d'un des multiples dossiers et images en php et mySQL [ par timZeR0 ] Salut tous le monde . J'ai utiliser une source pour envoyer des images sur un site grâce a php , mais maintenant , il me reste un problème ... comment URL+ereg_replace+_blank [ par yanka ] Est-ce que quelqu'un saurait comment on peut dans un champ $texte remplacer une portion de code de type: \"http://www.monsite.com\"</FONT retour a la racine [ par mogmog ] Bonjour!Quelle est la commande pour se placer directement sous la racine?par exemple, si je suis a: sous dossier_4/ http://monsite.fr/dossier_1/dossie Traiter des jpg cmjn [ par arnaud98 ] Bonjour à tousJe vous sollicite pour un ptit coup d'mainVoilà je voudrais traiter des images (insérer du texte à l'image par exemple), pour cela, j'ut Upload , nom d'image, BDD mysql [ par Grumo ] Bonjour à tous,voilà je me suis constitué un petit formulaire me permettant  d'uploader des images dans une bdd msql (enfin leur nom); ce script me ge Réduction d'images [ par Evangun ] Bonjour! Je me demandais : Existe-t-il une fonction pour réduire les bmp et/ou les convertir en jpg à l'instar de ce que fait GD avec les jpg, gif et Interpréter les images [ par CyberP ] Quelqu'un sait-il s'il y a un moyen de faire une image dynamique (avec gd par exemple) dont l'extension soit en .jpg ? (je ne parle pas du format, mai Lien > Remplace... [ par Tilix ] Salut, Alors voilà, j'ai une variable : $texte = "Mon site perso http://www.monsite.com"; Le site de cette variable peut changer. Je voudrais savoir Cacher l'url de la la page sur laquelle je suis!!!!!!!!!!! [ par ludovicanceaux ] Salut à tous, En ce moment je buche sur un truc, comment je pe faire pour cacher l'url o fur et à mesure de la navigation de mon siteex: pour garder h


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

Photothèque

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,796 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales