Probleme avec la fonction mail
Posté : 12 juil. 2006, 17:19
Bonjour à tous voilà j'essaye d'envoyer un mail en php avec mise en page html.
Cet email récupère les informations d'une page style recapitulatif de commande ( nom, prenom,adresse etc et bien sur le panier).
Pour recupérer les adresses,nom etc et les envoyer pas de probleme mais pour le panier c'est tout autre chose car comme je vais vous montré dans mon code j'ai mis une boucle "do while" pour que quand il y a un article différent cela créer une autre ligne.
Mais le soucis c'est que l'on ne peut pas mettre du php dans la fonction mail
Voici le code qui me pose soucis :
Et aussi si il serait possible de mettre le code que je vais mettre dessous dans une fonction et dans un fichier à part et si oui comment on fait.
Voila mon code de la fonction mail :
Cet email récupère les informations d'une page style recapitulatif de commande ( nom, prenom,adresse etc et bien sur le panier).
Pour recupérer les adresses,nom etc et les envoyer pas de probleme mais pour le panier c'est tout autre chose car comme je vais vous montré dans mon code j'ai mis une boucle "do while" pour que quand il y a un article différent cela créer une autre ligne.
Mais le soucis c'est que l'on ne peut pas mettre du php dans la fonction mail
Voici le code qui me pose soucis :
<?php do { ?>
<tr>
<td><div align="center">'.$nomArti.'</div></td>
<td><div align="center">'.$prixUni.'</div></td>
<td><div align="center">'.$Qu.'</div></td>
<td><div align="center">'.$prixArti.'</div></td>
</tr>
<?php } while ($row_Recordset4 = mysql_fetch_assoc($Recordset4)); ?>
Et aussi si il serait possible de mettre le code que je vais mettre dessous dans une fonction et dans un fichier à part et si oui comment on fait.
Voila mon code de la fonction mail :
<?php
$adresse = "mon mail";
$sujet = "Confirmation de votre commande\n\n";
$texte=' <html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p> '.$etatC.' '.$nom.' '.$prenom.',</p>
<p>Merci d\'avoir passé commande chez <strong>ATLANTIC BARS<strong>
<strong><br>Conservez ce mail car il tient lieu de facture. </strong></p>
<table width="429" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="225">Commande n° '.$clientID.'</td>
<td width="204">du '.$date.' </td>
</tr>
</table>
<br>
<table width="559" border="0" cellspacing="0">
<tr>
<td width="166"><div align="center">Désignation</div></td>
<td width="138"><div align="center">Prix Unitaire </div></td>
<td width="112"><div align="center">Quantité</div></td>
<td width="135"><div align="center">Prix Article </div></td>
</tr>
<tr>
<td>---------------------------</td>
<td>-----------------------</td>
<td>------------------</td>
<td>----------------------</td>
</tr>
<?php do { ?>
<tr>
<td><div align="center">'.$nomArti.'</div></td>
<td><div align="center">'.$prixUni.'</div></td>
<td><div align="center">'.$Qu.'</div></td>
<td><div align="center">'.$prixArti.'</div></td>
</tr>
<?php } while ($row_Recordset4 = mysql_fetch_assoc($Recordset4)); ?>
</table>
---------------------------------------------------------------------------------------------------------------<br>
<table width="581" border="0" cellspacing="0">
<tr>
<td width="202"> </td>
<td width="375"><table width="284" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="118"><div align="center">Total T.T.C : </div></td>
<td width="166"><div align="center">'.$totalc.' </div></td>
</tr>
</table></td>
</tr>
</table>
<p><strong>Adresse de livraison :</strong></p>
<p><strong>Nom :</strong> '.$nom.'<br>
<strong>Prenom : </strong>'.$prenom.'<br>
<strong> Adresse : </strong>'.$adress.'<br>
<strong>Code postal : </strong>'.$cp.' <br>
<strong>Ville : </strong>'.$ville.'<br>
<strong>Téléphone : </strong>'.$tel.'<br>
<strong>Mail :</strong> '.$mail.'</p>
<p><strong>Adresse de facturation :</strong><br>
<br>
<strong>Nom :</strong> '.$nomf.'<br>
<strong>Prenom : </strong>'.$prenomf.'<br>
<strong>Adresse : </strong>'.$adressef.'<br>
<strong>Code postal :</strong> '.$cpf.' <br>
<strong>Ville : </strong>'.$villef.'<br>
<strong>Téléphone : </strong>'.$telf.'<br>
<strong>Mail :</strong> '.$mailf.' <br>
<p>Merci de votre visite, en espérant vous revoir bientôt.</p>
</body>
</html>
';
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: '.mailf.'\n";
mail ($adresse, $sujet, $texte,$headers);
?>
Merci à tous j'attend votre aide avec impatiance.