Mail format HTML qui arrive en format texte
Dead
-
Webm -
Webm -
Bonjour à tout le monde !
J'ai donc un soucis : lorsque je veux envoyer un mail au format HTML, ce dernier part bien, mais arrive à destination au format texte, le code n'est pas du tout interprété...
J'ai testé en envoyant ce mail via Gandi Webmail et Zimbra Free, vers l'un puis vers l'autre. Ça m'a suffit à en conclure que j'avais un soucis.
Je vous contrebalance une version le code avec une version light de son conteu, si vous pouvez m'aider :-/
D'avance merci !
************************************************************************
<html>
<head>
<title>titre de la page</title>
<style type="text/css">
body{
background-color: #31435A;
background-attachment: fixed;
background-image: url(img/bckg.jpg);
background-position: top left;
background-repeat: repeat;
}
#logo{
width: 210px;
height: 119px;
background-image: url(img/logo.jpg);
background-repeat: no-repeat;
position: relative;
margin-left: auto;
margin-right: auto;
}
.contenu{
background-color: black;
width: 500px;
height: auto;
position: relative;
margin-left: auto;
margin-right: auto;
padding: 7px 7px 7px 7px;
color:#FFFFFF;
}
.text p{
text-align: left;
font-family:Verdana;
font-size:12px;
color:#cccccc;
}
.text a{
font-family:Verdana;
font-size:12px;
color:#45A72C;
text-decoration: underline;
}
.text a:hover{
font-family:Verdana;
font-size:12px;
color:#45A72C;
text-decoration:none;
}
.right{
text-align: right !important;
}
.html{
margin-left: auto;
margin-right: auto;
position: relative;
width:-moz-max-content;
}
.advert p{
font-family:Verdana;
font-size:8px;
color:#cccccc;
}
.advert a{
font-family:Verdana;
font-size:8px;
color:#45A72C;
text-decoration: underline;
}
.advert a:hover{
font-family:Verdana;
font-size:8px;
color:#45A72C;
text-decoration:none;
}
.events{
font-weight: bold;
color:#45A72C;
font-size: 10px;
}
</style>
</head>
<body>
<div class="html"><span class="advert"><p>Si vous ne parvenez pas à lire ce mail correctement, vous pourrez le visionner sur internet en cliquant ici</p></span></div>
<br/>
<br/>
<div id="logo"></div>
<div class="contenu">
<span class="text">
<p>texte</p>
</span>
</div>
</body>
</html>
************************************************************************
J'ai donc un soucis : lorsque je veux envoyer un mail au format HTML, ce dernier part bien, mais arrive à destination au format texte, le code n'est pas du tout interprété...
J'ai testé en envoyant ce mail via Gandi Webmail et Zimbra Free, vers l'un puis vers l'autre. Ça m'a suffit à en conclure que j'avais un soucis.
Je vous contrebalance une version le code avec une version light de son conteu, si vous pouvez m'aider :-/
D'avance merci !
************************************************************************
<html>
<head>
<title>titre de la page</title>
<style type="text/css">
body{
background-color: #31435A;
background-attachment: fixed;
background-image: url(img/bckg.jpg);
background-position: top left;
background-repeat: repeat;
}
#logo{
width: 210px;
height: 119px;
background-image: url(img/logo.jpg);
background-repeat: no-repeat;
position: relative;
margin-left: auto;
margin-right: auto;
}
.contenu{
background-color: black;
width: 500px;
height: auto;
position: relative;
margin-left: auto;
margin-right: auto;
padding: 7px 7px 7px 7px;
color:#FFFFFF;
}
.text p{
text-align: left;
font-family:Verdana;
font-size:12px;
color:#cccccc;
}
.text a{
font-family:Verdana;
font-size:12px;
color:#45A72C;
text-decoration: underline;
}
.text a:hover{
font-family:Verdana;
font-size:12px;
color:#45A72C;
text-decoration:none;
}
.right{
text-align: right !important;
}
.html{
margin-left: auto;
margin-right: auto;
position: relative;
width:-moz-max-content;
}
.advert p{
font-family:Verdana;
font-size:8px;
color:#cccccc;
}
.advert a{
font-family:Verdana;
font-size:8px;
color:#45A72C;
text-decoration: underline;
}
.advert a:hover{
font-family:Verdana;
font-size:8px;
color:#45A72C;
text-decoration:none;
}
.events{
font-weight: bold;
color:#45A72C;
font-size: 10px;
}
</style>
</head>
<body>
<div class="html"><span class="advert"><p>Si vous ne parvenez pas à lire ce mail correctement, vous pourrez le visionner sur internet en cliquant ici</p></span></div>
<br/>
<br/>
<div id="logo"></div>
<div class="contenu">
<span class="text">
<p>texte</p>
</span>
</div>
</body>
</html>
************************************************************************
A voir également:
- Mail reçu en texte brut
- Transcription audio en texte word gratuit - Guide
- Publipostage mail - Accueil - Word
- Windows live mail - Télécharger - Mail
- Excel cellule couleur si condition texte - Guide
- Mettre un texte en majuscule - Guide
5 réponses
Où est le code PHP de l'envoi du mail?
Dead
Je ne savais même pas qu'il fallait en mettre :-/ Pourquoi ? Je ne touche pas un poil de PHP
il faut que tu indique en php le content type
$From .= "Content-type: text/html; charset= iso-8859-1\n";;
vu sur http://www.asp-php.net/ressources/bouts_de_code.aspx?id=35
vu ton exemple, tu peut aussi envoyer l'email en html+texte
il y a des exemples sur le net, ex : http://www.progmatique.fr/article-118-Php-comment-envoyer-email.html
++
$From .= "Content-type: text/html; charset= iso-8859-1\n";;
vu sur http://www.asp-php.net/ressources/bouts_de_code.aspx?id=35
vu ton exemple, tu peut aussi envoyer l'email en html+texte
il y a des exemples sur le net, ex : http://www.progmatique.fr/article-118-Php-comment-envoyer-email.html
++
Exemple de mail au format HTML
<!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 content="text/html; charset=latin1" http-equiv="Content-Type" /> <title>Commande Envoie</title> </head> <body> <?php session_start(); //Connexion à la base de données mysql_connect('localhost', 'root', ''); mysql_select_db('mcad2010'); $headers ='From: '.$_SESSION['nom'].'<commande@blabla.com>'."\n"; $headers .='Reply-To: '.$_SESSION['mail'].''."\n"; $headers .='Content-Type: text/html; charset="iso-8859-1"'."\n"; $headers .='Content-Transfer-Encoding: 8bit'; // La requête sql pour récupèrer les messages de la page actuelle. $retour_messages=mysql_query('SELECT * FROM panier WHERE id = "'.$_SESSION['id'].'"'); while($donnees_messages=mysql_fetch_assoc($retour_messages)) // On lit les entrées une à une grace à une boucle { $message .='<html><head><title>Commande</title></head><body><table bgcolor="silver" style="color:purple" width="900" align="center" border="1"> <tr> <th>Nom</th> <th>Prenom</th> <th>Societe</th> <th>Tel. Fix</th> <th>Tel. Port</th> <th>Mail</th> <th>Ref</th> <th>Designation</th> <th>Quantité</th> <th>Prix</th> </tr> <tr> <td>'.$_SESSION['nom'].'</td> <td>'.$_SESSION['prenom'].'</td> <td>'.$_SESSION['societe'].'</td> <td>'.$_SESSION['telfix'].'</td> <td>'.$_SESSION['telport'].'</td> <td>'.$_SESSION['mail'].'</td> <td>'.$donnees_messages['Ref'].'</td> <td>'.$donnees_messages['Designation_du_site'].'</td> <td>'.$donnees_messages['Quantite'].'</td> <td>'.$donnees_messages['Prix'].'</td> </tr> </table> </body></html><br/>'; } if(mail('bla@blabla.com', 'Commande', $message, $headers)) { header('location:fin_commande.php'); } else { echo 'Le message n\'a pu être envoyé'; } ?> </body> </html>
Merci pour cet exemple mais si j'ai bien compris, celui qui a fait ce mail y appel des infos récupérées dans une bdd, c'est à mon sens comme je le comprends, la seule raison pour laquelle il utilise du PHP. Cependant, il semble primordial d'en utiliser dans tous les cas de mail en HTML.
Cependant, la seule partie qui semble m'intéresser serait celle-ci :
while($donnees_messages=mysql_fetch_assoc($retour_messages)) // On lit les entrées une à une grace à une boucle
{
$message .='<html><head><title>Commande</title></head><body>
blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
</body></html><br/>';
}
Je me trompe ou bien ?
Cependant, la seule partie qui semble m'intéresser serait celle-ci :
while($donnees_messages=mysql_fetch_assoc($retour_messages)) // On lit les entrées une à une grace à une boucle
{
$message .='<html><head><title>Commande</title></head><body>
blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
</body></html><br/>';
}
Je me trompe ou bien ?
dans cette partie je récupere chaque ligne mon tableau, et je concatene ma variable pour envoyer toute les ligne de mon tableau
cependant a la place de mes variable qui récupere les ligne j'aurais pu mettre les info d'un formulaire a l'aide de la méthode POST
exemple :
cependant a la place de mes variable qui récupere les ligne j'aurais pu mettre les info d'un formulaire a l'aide de la méthode POST
exemple :
$message .='<html><head><title>Commande</title></head><body><table bgcolor="silver" style="color:purple" width="900" align="center" border="1"> <tr> <th>Nom</th> <th>Prenom</th> <th>Societe</th> <th>Tel. Fix</th> <th>Tel. Port</th> <th>Mail</th> <th>Ref</th> <th>Designation</th> <th>Quantité</th> <th>Prix</th> </tr> <tr> <td>'.$_POST['nom'].'</td> <td>'.$_POST['prenom'].'</td> <td>'.$_POST['societe'].'</td> <td>'.$_POST['telfix'].'</td> <td>'.$_POST['telport'].'</td> <td>'.$_POST['mail'].'</td> </tr> </table> </body></html><br/>'; }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
voici un site génial
http://ww17.mynetactu.net/index.php?module=membres&action=mail_html
j'ai déjà éssayé et ça marche
http://ww17.mynetactu.net/index.php?module=membres&action=mail_html
j'ai déjà éssayé et ça marche