[Mail] Envois d'e-mails au format texte et html
Bonjour,
j'ai récupéré un script qui permet l'envoi d'un mail au format texte et html et s'affiche soit en texte soit en html en fonction je crois du navigateur et de l'outils de gestion des messages. Alors quand j'envoie le mail, il arrive au format texte et suivi du code html (sans affichage html). Pouvez-vous m'indiquer ce qu'il faut faire ?
Voilà le code :
Code:
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
|
<?php
//-----------------------------------------------
//DECLARE LES VARIABLES
//-----------------------------------------------
$destinataire='mail_destinataire@fai.fr';
$email_expediteur='votre_mail@fai.fr';
$email_reply='email_de_reponse@fai.fr';
$message_texte='Bonjour,'."\n\n".'Voici un message au format texte';
$message_html='<html>
<head>
<title>Titre</title>
</head>
<body>Test de message</body>
</html>';
//-----------------------------------------------
//GENERE LA FRONTIERE DU MAIL ENTRE TEXTE ET HTML
//-----------------------------------------------
$frontiere = '-----=' . md5(uniqid(mt_rand()));
//-----------------------------------------------
//HEADERS DU MAIL
//-----------------------------------------------
$headers = 'From: "Nom" <'.$email_expediteur.'>'."\n";
$headers .= 'Return-Path: <'.$email_reply.'>'."\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= 'Content-Type: multipart/alternative; boundary="'.$frontiere.'"';
//-----------------------------------------------
//MESSAGE TEXTE
//-----------------------------------------------
$message = 'This is a multi-part message in MIME format.'."\n\n";
$message .= '--'.$frontiere.'--'."\n";
$message .= 'Content-Type: text/plain; charset="iso-8859-1"'."\n";
$message .= 'Content-Transfer-Encoding: 8bit'."\n\n";
$message .= $message_texte."\n\n";
//-----------------------------------------------
//MESSAGE HTML
//-----------------------------------------------
$message .= '--'.$frontiere.'--'."\n";
$message .= 'Content-Type: text/html; charset="iso-8859-1"'."\n";
$message .= 'Content-Transfer-Encoding: 8bit'."\n\n";
$message .= $message_html."\n\n";
$message .= '--'.$frontiere.'--'."\n";
if(mail($destinataire,$sujet,$message,$headers))
{
echo 'Le mail a été envoyé';
}
else
{
echo 'Le mail n\'a pu être envoyé';
}
?> |
Je vous remercie d'avance !
[Mail] envois de mail au format texte et html
Bonjour,
j'ai un souci au niveau de l'affichage des mails envoyés. En effet j'ai un serveur linux et code en php.Lorsque j'envoie le mail au format html et texte je ne reçois pas le mél sur Outlook Express, mais je reçois sur Webmail, mais lorsque c'est au format texte je les reçois sur les deux mais le saut de ligne n'est pas pris en compte.
Voilà mon code
Code:
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
|
<?php
//--Constitution des paramètres des liens du message du mail.
$leparam=substr($ref,0,4).strtoupper(md5("OUI")).substr($ref,-4);
//$lien="http://www.Market.org/default.php?Bib_conf=".$leparam;
$lien1="http://Market.acatmp.org/index.php?Bib_conf=".$leparam."&Bib_con=mofin";
$lien2="http://Market.acatmp.org/index.php?Bib_conf=".$leparam."&Bib_con=minfo";
$destinataire=$mail;
//$expediteur="service_bib69@Market.com";
//$mail_reply="service_bib69@Market.com";
$sujet="Des Nouveaux partenaires dans BIB69";
//--Message Texte
$message_texte="Bonjour jean Lucien,\n";
$message_texte="Comment as-tu passé le week-end ?\n";
$message_texte="C'est avec plaisir que je t'invite au dîner ce soir.\n";
$message_texte="Repond moi vite !\n";
//--Message Html Debut
$message_html="<html><head><link rel=\"stylesheet\" href=\"http://Market.acatmp.org/Market_Nl.css\" type=\"text/css\">";
$message_html.="<style type=\"text/css\">";
$message_html.="*#cadre_haut_nletter { background-image:url(http://Market.acatmp.org/images/tab_haut_nletter.gif)}";
$message_html.="*#cadre_centre_nletter { background-image:url(http://Market.acatmp.org/images/tab_milieu_nletter.gif)}";
$message_html.="*#cadre_bas_nletter { background-image:url(http://Market.acatmp.org/images/tab_bas_nletter.gif)}";
$message_html.="*#Tab_trois{border-right-style:solid;border-right-width:1px;border-right-color:#FFCC00;border-bottom-style:solid;border-bottom-width:1px;border-bottom-color:#FFCC00;border-left-style:solid;border-left-width:1px;border-left-color:#FFCC00;padding:0px;text-ident:2px;}";
$message_html.="*#Titre_N1 {font-family: Arial,Helvetica,sans-serif;font-size:11px;font-weight:bolder;text-transform:uppercase;color: #FFFFFF;background-color:#FFCC00;letter-spacing:3px;text-ident:3pt;padding-left:5px;}";
$message_html.="td {font-family: Arial, Helvetica, sans-serif;font-size: 10px;font-weight: bold;color: #DEDEDE;}";
$message_html.="*#t_a {font-family: Times New romans,Arial,verdana, Helvetica, sans-serif;font-size: 10px;font-weight: bold;color: #000000;}";
$message_html.="*#text0 {font-family: Arial, Helvetica, sans-serif;font-size: 10px;font-weight: bold;color: #333300;}";
$message_html.="</style></head>";
$message_html.="<body text=\"#000000\" link=\"#990000\" vlink=\"#990000\" alink=\"#990000\" text-decoration=\"underline\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">";
$message_html.="<center><table width=\"640\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" bgcolor=\"#FFFFFF\">";
$message_html.="<tr><td height=\"6\" id=\"cadre_haut_nletter\" valign=\"top\" ></td></tr>";
$message_html.="<tr><td width=\"640\" id=\"cadre_centre_nletter\" valign=\"top\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
$message_html.="<tr><td width=\"150\" valign=\"top\" align=\"center\"><img src=\"http://Market.acatmp.org/images/logo_Market.gif\" border=\"0\">";
$message_html.="</td><td width=\"490\" valign=\"bottom\" align=\"center\"><img src=\"http://Market.acatmp.org/images/pub/pub_toi_et_moi.jpg\" border=\"0\">";
$message_html.="</td></tr></table><table ><tr><td width=\"640\" valign=\"top\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
$message_html.="<tr><td colspan=\"2\" bgcolor=\"navy\"> </td></tr><tr bgcolor=\"#FFCC00\"><td colspan=\"2\" height=\"5\"></td></tr>";
$message_html.="<tr><td colspan=\"2\" bgcolor=\"#969696\"><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
$message_html.="<tr><td>VOTRE PSEUDO : <span class=\"text0\" >Jean</span></td><td align=\"right\">Mot de Passe Oublié, <span class=\"text0\">";
$message_html.="<a href=\"http://Market.acatmp.org/Membres/coordonnees_perdu.php\" target=\"_blanc\">Cliquer ici</a></span></td></tr>";
$message_html.="<tr><td colspan=\"2\"> </td></tr><tr><td colspan=\"2\" id=\"t_a\"><ul>";
$message_html.="Bonjour Jean Lucien ,<br> ";
$message_html.="Comment as-tu passé le week-end ?";
$message_html.="C'est avec plaisir que je t'invite au dîner ce soir.<br> Repond moi vite !</td></tr>";
$message_html.="</table><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td><table cellpadding=\"0\" cellspacing=\"2\" width=\"100%\">";
$message_html2.="<tr><td colspan=\"2\"> </td></tr></table></td></tr></table><table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
$message_html2.="<tr><td width=\"32%\"><table cellpadding=\"0\" cellspacing=\"2\" width=\"100%\"><tr><td id=\"Titre_N1\">Infos Market </td><td > </td></tr>";
$message_html2.="<tr><td colspan=\"2\" ><table width=\"100%\" cellpadding=\"0\" cellspacing=\"2\" id=\"Tab_trois\"><tr><td width=\"99%\">";
$message_html2.="<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td id=\"t_a\" align=\"justify\">";
$message_html2.=" Vous souhaitez avoir des informations sur Market ? vous pouvez nous contacter en cliquant <span class=\"msgr\">";
$message_html2.="<a href=\"http://Market.acatmp.org/ToutBib/contact.php\" target=\"_blanc\">ici</a></span><br> </td></tr></table>";
$message_html2.="</td><td width=\"1%\"> </td></tr></table></td></tr><tr><td colspan=\"2\"> </td></tr></table>";
$message_html2.="</td><td width=\"34%\"><table cellpadding=\"0\" cellspacing=\"2\" width=\"100%\"><tr><td id=\"Titre_N1\">Vos Infos </td><td > </td></tr>";
$message_html2.="<tr><td colspan=\"2\" ><table width=\"100%\" cellpadding=\"0\" cellspacing=\"2\" id=\"Tab_trois\"><tr><td width=\"99%\">";
$message_html2.="<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td id=\"t_a\" align=\"justify\">";
$message_html2.=" Vous souhaitez arrêter momentanément ou définitivement votre compte chez Market ?";
$message_html2.=" Vous devez suivre ce lien en cliquant par <span class=\"msgr\"><a href=". $lien1 ." target=\"_blanc\">ici</a></span>";
$message_html2.="</td></tr></table></td><td width=\"1%\"> </td></tr></table></td></tr><tr><td colspan=\"2\"> </td></tr>";
$message_html2.="</table></td><td width=\"34%\"><table cellpadding=\"0\" cellspacing=\"2\" width=\"100%\">";
$message_html2.="<tr><td id=\"Titre_N1\">Infos Bib69</td><td > </td></tr><tr><td colspan=\"2\" >";
$message_html2.="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"2\" id=\"Tab_trois\"><tr><td width=\"99%\">";
$message_html2.="<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td id=\"t_a\" align=\"justify\" >";
$message_html2.="Vous avez la possibilité de vous désabonner de notre newsletter. Si c'est le cas,";
$message_html2.="il vous suffit de modifier vos options en cliquant <span class=\"msgr\"><a href=". $lien2 ." target=\"_blanc\">ici</a></span>";
$message_html2.="</td></tr></table></td><td width=\"1%\"> </td></tr></table></td></tr><tr><td colspan=\"2\"> </td></tr>";
$message_html2.="</table></td></tr></table></td></tr><tr bgcolor=\"#FFCC00\"><td colspan=\"2\" height=\"5\"></td></tr>";
$message_html2.="<tr bgcolor=\"navy\"><td colspan=\"2\"> </td></tr></table></table></td></td></tr>";
$message_html2.="<tr><td height=\"6\" id=\"cadre_bas_nletter\" ></td></tr></table>";
$message_html2.="<table><tr><td align=\"center\" id=\"text0\"> © Market - 2007 - Tous droits réservés";
$message_html2.=" </td></tr></table></center>";
$message_html2.="</body>";
$message_html2.="</html>";
$frontiere = "-----=".md5(uniqid(mt_rand()));
$headers ="From: JEAN-CLAUDE<services_market@market.com> \n";
$headers .="Return-Path: <services_market@market.com> \n";
$headers .="MIME-Version: 1.0 \n";
$headers .="Content-Type: multipart/alternative; boundary=\"".$frontiere."\" \n";
//--Message texte
$message_H="";
$message_H.= "--".$frontiere."--\n";
$message_T.= "Content-Type: text/plain ; charset=\"iso-8859-1\" \n";
$message_H.= "Content-Transfer-Encoding: 8bit \n";
$message_H.="\n".$message_texte."\n";
//--Message html
$message_H.= "--".$frontiere."--\n";
$message_H.= "Content-Type: text/html; charset=\"iso-8859-1\" \n";
$message_H.= "Content-Transfer-Encoding: 8bit \n";
$message_H.="\n".$message_html2."\n";
$message_H.= "--".$frontiere."--\n\n";
if(mail($destinataire,$sujet,$message_H,$headers)){
$letexte="Le mail a bien été envoyé.";
}else{
$letexte="Le mail n'a pas été envoyé.";
}
return $letexte;
?> |
Si vous avez une piste, merci de m'aider. Une question peut-être bête, est-ce qu'il est possible de faire un test pour un affichage en texte ou en html ?
Je vous remercie.
envoi de mail au format texte et html avec images en ligne
Bonjour,
j'ai vu une newsletter qui est envoyée à la fois au format texte et ua format html avec images en ligne.Dans la source du message, j'ai vu qu'ils ont utilisé à la fois le
Content-Type: multipart/related avec son Boundary et
Content-Type: multipart/alternative avec un autre Boundary
Mon problème c'est de savoir comment ils ont utilisés c'est deux content-type ? et comment ils ont alterné les frontières ?
Je vous remercie de votre aide !