envois de mail format html

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : envois de mail format html

Re: envois de mail format html (résolut)

par pacphil » 08 avr. 2012, 21:04

résolut
<?php
session_start(); 

include("cssstyle/haut.php");
include("sources/config.php");


$to = $_SESSION['email_ano'];
$sujet = $_SESSION['ref_ano'];
$subject = $_SESSION['ref_ano'];

     $image = 'http://www.h-immo.be/cssstyle/imdesign/logo.jpg';
	 $nom_expediteur=$_POST['name_con'];
	 $phone_expediteur=$_POST['phone_con'];
     $email_expediteur=$_POST['email_con'];
	 $com_expediteur=$_POST['comment_con'];
	 
	 
$boundary = md5(uniqid(rand()));

$headers = "From: ".$to."\r\n";
$headers .= "Reply-To: ".$email_expediteur."\r\n";
$headers .= "Return-Path: ".$email_expediteur."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

$message .= "--".$boundary."--";
$message  = "<html><body>";
$message .= "<img src=".$image." width=\"230\" height=\"142\" border=\"0\"><br />";
$message .= "<b>Réf annonce</b> :".$sujet."<br />";
$message .= "<b>Nom</b> :".$nom_expediteur."<br />";
$message .= "<b>Téléphone</b> :".$phone_expediteur."<br />";
$message .= "<b>Email</b> :".$email_expediteur."<br />";
$message .= "<b>Message</b> :".$com_expediteur."<br />";
$message .= "<a href=\"http://www.h-immo.be/detail_anno.php?detail=".$_SESSION['detail']."\">Voir le bien</a>";
$message .= "</body></html>";
$message .= "--".$boundary."--";

if ( mail($to,$subject,$message,$headers) ) {
   		echo'<script>
        $(document).ready(function() {
        $("#dialog").dialog({
	    modal: true,
		opacity: .80,
		});
        });
 	    setTimeout( function() { 
	    window.location.href = ("http://www.h-immo.be/detail_anno.php?detail='.$_SESSION['detail'].'");
	    }, 5000 ); 
        </script>
	    <div id="dialog" title="OK ENVOYER" style="display:none;"><img src="cssstyle/imdesign/1.gif" width="24" height="24" border="0"><br />
        Vous allez &ecirc;tre rediriger
        </div>';
   } else {
   		echo'<script>
        $(document).ready(function() {
        $("#dialog").dialog({
	    modal: true,
		opacity: .80,
		});
        });
 	    setTimeout( function() { 
	    window.location.href = ("http://www.'.$web_site.'/detail_anno.php?detail='.$_SESSION['detail'].'");
	    }, 5000 ); 
        </script>
	    <div id="dialog" title="ERREUR ENVOIS" style="display:none;"><img src="cssstyle/imdesign/1.gif" width="24" height="24" border="0"><br />
        Vous allez &ecirc;tre rediriger
        </div>';
   }
   
include("cssstyle/bas.php");	 
?>    

Re: envois de mail format html

par pacphil » 07 avr. 2012, 18:02

bonjour voilà j'ai encore quelque soucis mes les info passe maintenant je vous mais le code + le mail une fois reçu il ne s'affiche pas comme je le voudrais ?
<?php
session_start(); 

include("cssstyle/haut.php");
include("sources/config.php");
     //-----------------------------------------------
     //DECLARE LES VARIABLES
     //-----------------------------------------------

     $destinataire=$_SESSION['email_ano'];
	 $nom_expediteur=$_POST['name_con'];
	 $phone_expediteur=$_POST['phone_con'];
     $email_expediteur=$_POST['email_con'];
	 $com_expediteur=$_POST['comment_con'];
	 $sujet=$_SESSION['ref_ano'];
     $email_reply=$_SESSION['email_ano'];

     //-----------------------------------------------
     //GENERE LA FRONTIERE DU MAIL ENTRE TEXTE ET HTML
     //-----------------------------------------------
     srand((double)microtime()*1000000);
     $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.'"\n';

     //-----------------------------------------------
     //MESSAGE HTML
     //-----------------------------------------------
	 $message .='\nThis is multi-part Message in MINE format.';
     $message .= 'Content-Type: text/html; charset="iso-8859-1"'."\n";
     $message .= 'Content-Transfer-Encoding: 8bit'."\n\n";
	 $message .= '<html><body>\n';
     $message .= '<b>R&eacute;f annonce</b> :'.$sujet.'<br />\n';
	 $message .= '<b>Nom</b> :'.$nom_expediteur.'<br />\n';
	 $message .= '<b>T&eacute;l&eacute;phone</b> :'.$phone_expediteur.'<br />\n';
	 $message .= '<b>Email</b> :'.$email_expediteur.'<br />\n';
	 $message .= '<b>Message</b> :'.$com_expediteur.'<br />\n';
	 $message .= '</body></html>\n';
	 $message .= '\n--'.$frontiere.'--\n end of the multi-part';

     if(mail($destinataire,$sujet,$message,$headers))
     {
		echo'<script>
        $(document).ready(function() {
        $("#dialog").dialog({
	    modal: true,
		opacity: .80,
		});
        });
 	    setTimeout( function() { 
	    window.location.href = ("http://www.h-immo.be/detail_anno.php?detail='.$_SESSION['detail'].'");
	    }, 5000 ); 
        </script>
	    <div id="dialog" title=OK ENVOYER"><img src="cssstyle/imdesign/1.gif" width="24" height="24" border="0"><br />
        Vous allez &ecirc;tre rediriger
        </div>';
     }
     else
     {
		 
		echo'<script>
        $(document).ready(function() {
        $("#dialog").dialog({
	    modal: true,
		opacity: .80,
		});
        });
 	    setTimeout( function() { 
	    window.location.href = ("http://www.'.$web_site.'/detail_anno.php?detail='.$_SESSION['detail'].'");
	    }, 5000 ); 
        </script>
	    <div id="dialog" title="ERREUR ENVOIS"><img src="cssstyle/imdesign/1.gif" width="24" height="24" border="0"><br />
        Vous allez &ecirc;tre rediriger
        </div>';
     } 

include("cssstyle/bas.php");	 
?> 
voici a la réception
<html><body>\n<b>R&eacute;f annonce</b> :1NRHPW<br />\n<b>Nom</b> :paquot<br />\n<b>T&eacute;l&eacute;phone</b> :019.32.28.74<br />\n<b>Email</b> :[email protected]<br />\n<b>Message</b> :test contact annonce<br />\n</body></html>\n\n--04030c89b8186e0c95e77018a839e64a--\n end of the multi-part

Re: envois de mail format html

par Mazarini » 03 avr. 2012, 09:32

Moogli t'as donné le code :
var_dump($_POST,$_SESSION);
C'est à ajouter juste après le session_start()

A priori tu verras ce qu'il y a dans $_SESSION['ref_ano'] ou si la référence est dans un autre élément de $_SESSION.

Re: envois de mail format html

par pacphil » 03 avr. 2012, 09:23

var_dump comment stp?

Re: envois de mail format html

par moogli » 02 avr. 2012, 21:49

salut,

Essai de debugguer avec la fonction var_dump en debut de script pour voir ce que contiennent les variables (var_dump($_POST,$_SESSION); devrait aider.


@+

envois de mail format html

par pacphil » 02 avr. 2012, 19:34

Bonjour , j'ai un soucis j’envoie bien l'email le soucis c'est que je n'est que la référence de l’annonce, seriez vous m'aidez à le mettre au point et ajouter mon logo.

Merci d'avance voici le script ici dessous.
<?php
session_start(); 
include("cssstyle/haut.php");
include("sources/config.php");
     //-----------------------------------------------
     //DECLARE LES VARIABLES
     //-----------------------------------------------

     $destinataire=$_SESSION['email_ano'];
	 $nom_expediteur=$_POST['name_con'];
	 $phone_expediteur=$_POST['phone_con'];
     $email_expediteur=$_POST['email_con'];
	 $com_expediteur=$_POST['comment_con'];
	 $sujet=$_SESSION['ref_ano'];
     $email_reply=$_SESSION['email_ano'];

     /*$message_texte='Ref annonce'.$sujet.''; */
     $message_html='<html>
     <head>
     <title>H-immo</title>
     </head>
     <body>
	 <table width="361" height="203" border="0">
     <tr>
     <td width="83">Référence :</td>
     <td width="307">'.$sujet.'</td>
     </tr>
     <tr>
     <td>Nom :</td>
     <td>'.$nom_expediteur.'</td>
     </tr>
     <tr>
     <td>Téléphone :</td>
     <td>'.$phone_expediteur.'</td>
     </tr>
     <tr>
     <td>Email :</td>
     <td>'.$destinataire.'</td>
     </tr>
     <tr>
     <td>Message :</td>
     <td>'.$com_expediteur.'</td>
     </tr>
     </table>
	 </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'<script>
        $(document).ready(function() {
        $("#dialog").dialog({
	    modal: true,
		opacity: .80,
		});
        });
 	    setTimeout( function() { 
	    window.location.href = ("http://www.h-immo.be/detail_anno.php?detail='.$_SESSION['detail'].'");
	    }, 5000 ); 
        </script>
	    <div id="dialog" title=OK ENVOYER"><img src="cssstyle/imdesign/1.gif" width="24" height="24" border="0"><br />
        Vous allez &ecirc;tre rediriger
        </div>';
     }
     else
     {
		 
		echo'<script>
        $(document).ready(function() {
        $("#dialog").dialog({
	    modal: true,
		opacity: .80,
		});
        });
 	    setTimeout( function() { 
	    window.location.href = ("http://www.'.$web_site.'/detail_anno.php?detail='.$_SESSION['detail'].'");
	    }, 5000 ); 
        </script>
	    <div id="dialog" title="ERREUR ENVOIS"><img src="cssstyle/imdesign/1.gif" width="24" height="24" border="0"><br />
        Vous allez &ecirc;tre rediriger
        </div>';
     } 

include("cssstyle/bas.php");	 
?>