Php envoier un formulair par mail(urgent)

Résolu/Fermé
nesrin_bh Messages postés 1 Date d'inscription mercredi 20 octobre 2010 Statut Membre Dernière intervention 20 octobre 2010 - 20 oct. 2010 à 14:26
Nabla's Messages postés 18203 Date d'inscription mercredi 4 juin 2008 Statut Contributeur Dernière intervention 28 avril 2014 - 20 oct. 2010 à 15:06
Bonjour,
j'ai une page contact ou j'ai un formulaire dont lequel le client va remplir les champs et les envoier par mail.
je veux que je resoie ces mail sur le compte mail"commercial.mdirect@gnet.tn"

et voila mon code

<body>
<div id="apDiv9">
<form id="form1" name="form1" method="get" action="mailto:commercial.mdirect@gnet.tn">
<table width="569" height="384" border="0">
<tr>
<td height="51" colspan="4"><div align="center"><span class="Style76">Pour nous rejoindre, veuillez remplir
ce formulaire</span></div></td>
</tr>
<tr>
<td width="62"><span class="Style46">Nom</span><span class="Style47">*</span>  </td>
<td width="209"><input name="nom" type="text" class="st" id="nom" size="30" /></td>
<td width="89"><span class="Style46"><span class="Style12">Prénom</span>* </span>  </td>
<td width="192"><div align="right">
<input name="prenom" type="text" class="st" id="mail5" size="30" />
</div></td>
</tr>
<tr>
<td><span class="Style46">Entreprise </span></td>
<td colspan="3"><input name="entreprise" type="text" class="st" id="entreprise" size="83" /></td>
</tr>
<tr>
<td><span class="Style46">Email*</span>  </td>
<td><input name="mail" type="text" class="st" id="mail" size="30" /></td>
<td><span class="Style46">Votre site</span> </td>
<td><div align="right">
<input name="site" type="text" class="st" id="mail2" size="30" />
</div></td>
</tr>
<tr>
<td><span class="Style46">Ville,pays</span></td>
<td><span class="Style46">
<input name="ville" type="text" class="st" id="mail3" size="30" />
</span></td>
<td><span class="Style46"> Téléphone</span></td>
<td><div align="right"><span class="Style46">
<input name="tel" type="text" class="st" id="mail4" size="30" />
</span></div></td>
</tr>
<tr>
<td colspan="2"><span class="Style46">Comment avez-vous connu M.direct.com?   </span></td>
<td colspan="2"><div align="right"><span class="Style46">
<input name="comment" type="text" class="st" id="mail6" size="45" />
</span></div></td>
</tr>
<tr>
<td><span class="Style46">Sujet* </span></td>
<td colspan="3"><span class="Style46">
<input name="sujet" type="text" class="st" id="mail7" size="30" />
</span></td>
</tr>
<tr>
<td colspan="4"><span class="Style46">Votre message pour Mdirect.com </span></td>
</tr>
<tr>
<td height="110" colspan="4"><div align="center">
<p class="Style46">  <span class="Style9">
<textarea name="msg" cols="88" rows="6" class="st" id="mail8"></textarea>
</span></p>
<p class="Style46">
<input name="envoier" type="submit" class="BTN" id="envoier" value="Envoyer" />
</p>
</div></td>
</tr>
</table>
</form>';


<?php
$email =$_POST['mail'];
$to="commercial.mdirect@gnet.tn";
$headers .='From: '.$email.''."\n"; // Adresse expediteur
$headers .='Reply-To: '.$to.''."\n"; // Adresse Destinataire
$headers .='Content-Type: text/html; charset="iso-8859-1"'."\n";
$headers .='Content-Transfer-Encoding: 8bit';
$subject= $_POST ['sujet'];
$content= 'nom'.$_POST ['nom'].'prenom'.$_POST ['prenom'].'entreprise'.$_POST ['entreprise'].site.$_POST ['site'].'ville'.$_POST ['ville'].'tel'.$_POST ['tel'].'Comment avez-vous connu M.direct.com? '.$_POST ['comment'].'message'.$_POST ['msg'];


function mailer ( $to, $subject, $content, $headers ) {
if ( mail($to, $subject, $content, $headers) ) {
return true;
} else {
return false;
}
}
mailer($mail,$subject , $content, $headers);
?>




et voila le msg d'erreur que j'ai reçu



<br />
<b>Notice</b>: Undefined index: mail in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>286</b><br />
<br />
<b>Notice</b>: Undefined variable: headers in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>288</b><br />

<br />
<b>Notice</b>: Undefined index: sujet in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>292</b><br />
<br />
<b>Notice</b>: Undefined index: nom in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>293</b><br />
<br />

<b>Notice</b>: Undefined index: prenom in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>293</b><br />
<br />
<b>Notice</b>: Undefined index: entreprise in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>293</b><br />
<br />
<b>Notice</b>: Use of undefined constant site - assumed 'site' in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>293</b><br />

<br />
<b>Notice</b>: Undefined index: site in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>293</b><br />
<br />
<b>Notice</b>: Undefined index: ville in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>293</b><br />
<br />

<b>Notice</b>: Undefined index: tel in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>293</b><br />
<br />
<b>Notice</b>: Undefined index: comment in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>293</b><br />
<br />
<b>Notice</b>: Undefined index: msg in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>293</b><br />

<br />
<b>Notice</b>: Undefined variable: mail in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>303</b><br />
<br />
<b>Warning</b>: mail() [<a href='function.mail'>function.mail</a>]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in <b>C:\Users\nesrine\Desktop\site\contacte.php</b> on line <b>297</b><br />



svp aidez moi c'est urgent






A voir également:

3 réponses

Nabla's Messages postés 18203 Date d'inscription mercredi 4 juin 2008 Statut Contributeur Dernière intervention 28 avril 2014 3 192
20 oct. 2010 à 15:02
1- changes ton titre, y a pas d'urgence

2-
$headers .='From: '.$email.''."\n"; // Adresse expediteur
$headers .='Reply-To: '.$to.''."\n"; // Adresse Destinataire
$headers .='Content-Type: text/html; charset="iso-8859-1"'."\n";
$headers .='Content-Transfer-Encoding: 8bit';

ouais, c'est bien, mais dans ta première ligne, c'est un = qu'il faut mettre, ou alors faire uen petit $headers = "" avant pour créer la variable ...
-1
Nabla's Messages postés 18203 Date d'inscription mercredi 4 juin 2008 Statut Contributeur Dernière intervention 28 avril 2014 3 192
20 oct. 2010 à 15:04
et pour le reste ...

<form id="form1" name="form1" method="get" action="mailto:commercial.mdirect@gnet.tn">



$_POST['mail'];
$subject= $_POST ['sujet'];
$content= 'nom'.$_POST ['nom'].'prenom'.$_POST ['prenom'].'entreprise'.$_POST ['entreprise'].site.$_POST ['site'].'ville'.$_POST ['ville'].'tel'.$_POST ['tel'].'Comment avez-vous connu M.direct.com? '.$_POST ['comment'].'message'.$_POST ['msg'];


alors avant de crier a l'urgence, regardes ton code et prends le temsp d'y réfléchir ...
-1
Nabla's Messages postés 18203 Date d'inscription mercredi 4 juin 2008 Statut Contributeur Dernière intervention 28 avril 2014 3 192
20 oct. 2010 à 15:06
ha, et pour finir:

action="mailto:commercial.mdirect@gnet.tn">
==> ca ca va ouvrir la page du client mail de la personne ....

il faut mettre la page de ton traitement php
-1