Probleme envoi de mail: sendmail.php

Résolu/Fermé
chaspli Messages postés 45 Date d'inscription mardi 31 juillet 2007 Statut Membre Dernière intervention 11 juin 2011 - 25 janv. 2010 à 16:17
chaspli Messages postés 45 Date d'inscription mardi 31 juillet 2007 Statut Membre Dernière intervention 11 juin 2011 - 26 janv. 2010 à 16:07
Bonjour,

Je ne parviens pas a configurer correctement l'envoi des mails via mon formulaire .....
Pouvez vous m'aider à trouver mon erreur ?

Adresse du formulaire :
http://www.seloger-a-paris.fr/contact_agence_immobiliere_paris.html

réception des information:
http://www.seloger-a-paris.fr/sendmail.php

Merci d'avance
CH

A voir également:

4 réponses

zcrew Messages postés 231 Date d'inscription lundi 23 février 2004 Statut Membre Dernière intervention 26 février 2010 25
26 janv. 2010 à 11:09
Quelle est l'erreur exactement ?

En survolant en diagonale on voit que
Header("Location: http://www.seloger-a-paris.fr/merci_mail.html<URL de la page de remerciement>");

devrait être
Header("Location: http://www.seloger-a-paris.fr/merci_mail.html");

Ensuite le 4° paramètre de la fonction mail n'est pas très utile, perso je le supprimerais...

Enfin $subject n'est jamais définie,

donc pour moi tu devrais avoir :

$from= "contact@seloger-a-paris.fr";
$subject = "envoi de formulaire";
$message = "";
while (list($key, $val) = each($HTTP_POST_VARS)) {
$message .= "$key : $val\n";
}
mail($from, $subject, $message);
Header("Location: http://www.seloger-a-paris.fr/merci_mail.html");

Et dernière chose : tu ne peux pas utiliser "header" après le début de l'affichage de la page... soit tu fais ton envoi et ta redirection sans rien afficher, soi tu utilises une redirection javascript
1
le_joker_fou Messages postés 764 Date d'inscription mercredi 5 août 2009 Statut Membre Dernière intervention 7 août 2014 239
26 janv. 2010 à 13:56
Salut,

je ne reviendrais pas sur ce que zcrew a dit pour ne pas polluer, je vais juste compléter ses dires sur le header.

Le header ne peut pas être utilisé après des balise html, c'est pour cela qu'il te met un message d'erreur.

Petit conseil au passage, dans tes deux pages que tu nous donne tu refais à chaque fois la présentation (menu, bannière, etc...) pour te faciliter la vie créer une page type avec la bannière, le menu, etc.. et tu créer un corps de page ou tu insères la page appelée. Cela aura pour but de ne pas retaper x fois le même code et surtout d'être plus souple dans la programmation.

exemple : si tu dois modifier le menu tu vas devoir le faire sur toutes les pages or que avec mon conseil tu n'auras plus qu'à le faire sur une page.

voici un code type pour la page index.php

<html>
<head>
<title>page type</title>
</head>

<body>
<div id="banniere">
<img="...">
</div>
<div id="menu">
<a href="...">page1</a><br/>
<a href="...">page2</a><br/>
<a href="...">page3</a><br/>
...
</div>
<div id="corps">
<?php
$page=$_GET['page'];
include("page.php");
?>
</div>
</body>
</html>

Voilà avec ça plus besoin de retaper x fois le design de ta page et si tu dois modifier le menu ou la bannière tu ne le fais que une fois.

Mais pour en revenir à ton problème d'envoi de mail, supprime le 4° paramètre de la fonction, il n'est utile que si tu envois des mail ou format html.
1
le_joker_fou Messages postés 764 Date d'inscription mercredi 5 août 2009 Statut Membre Dernière intervention 7 août 2014 239
25 janv. 2010 à 16:26
Salut,

nous donner l'adresse des page internet ne nous est pas très utile car on ne peut pas voir le code. tu utilise quelle fonction pour envoyer tes mails? fonction mailto, fonction mail, ...
0
chaspli Messages postés 45 Date d'inscription mardi 31 juillet 2007 Statut Membre Dernière intervention 11 juin 2011
25 janv. 2010 à 17:27
J'utilise la fonction de base POST: formulaire -->sendmail.php-->redirection

Voici le code de la page formulaire :

<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Agence immobilière LOW COST :seloger-a-paris.fr Contacter nous. Estimation immobilière, Achat Vente, Location</title>
<meta name="description" content="Nous contacter. seloger-a-paris.fr :Paris, et Ile de France. Du studio au château">
<meta name="keywords" content="achat,vente,location,logement,appartement,immobilier,maison,annonces,immobilières,ventes,vendre,louer,terrain,commerces,parking,seloger-a-paris.fr, seloger paris ">
<meta name="author" content="Idais">
<meta name="reply-to" content="contact@seloger-a-paris.com">
<meta name="language" content="fr">
<meta name="copyright" content="seloger-a-paris.com">
<meta name="revisit-after" content="7 days">
<meta name="expires" content="never">
<meta name="robots" content="all">
<meta name="rating" content="Immobilier - Paris - achat- vente"><!-- DEBUT DU SCRIPT -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="mm_health_nutr.css" type="text/css" />
<script language="JavaScript" type="text/javascript">
//--------------- LOCALIZEABLE GLOBALS---------------
var d=new Date();
monthname= new Array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
//--------------- END LOCALIZEABLE ---------------
</script>
<style type="text/css">
<!--
.Style1 {font-size: 12px}
-->
</style>
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<form name="seloger-a-paris.fr" method="post" action="sendmail.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#D5EDB3">
<td width="459" colspan="3" rowspan="2"><img src="images_site_seloger_a_paris/bando.jpg" width="382" height="101" /></td>
<td width="551" height="50" colspan="3" id="logo" valign="bottom" align="center" nowrap="nowrap">Seloger-à-Paris.<em>fr</em></td>
<td width="20%"> </td>
</tr>

<tr bgcolor="#D5EDB3">
<td height="51" colspan="3" id="tagline" valign="top" align="center" width="551">Du studio au Château</td>
<td width="20%"> </td>
</tr>

<tr>
<td colspan="7" bgcolor="#5C743D" width="1260"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
</tr>

<tr>
<td colspan="7" bgcolor="#99CC66" background="mm_dashed_line.gif" width="1260"><img src="mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
</tr>

<tr bgcolor="#99CC66">
<td colspan="7" id="dateformat" height="20" width="1260">  <script language="JavaScript" type="text/javascript">
document.write(TODAY); </script> </td>
</tr>
<tr>
<td colspan="7" bgcolor="#99CC66" background="mm_dashed_line.gif" width="1260"><img src="mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
</tr>

<tr>
<td colspan="7" bgcolor="#5C743D" width="1260"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
</tr>

<tr>
<td width="165" valign="top" bgcolor="#5C743D">
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"> <br />
 <br /> <table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="index.html">Accueil</a></td>
</tr>
</table></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="page_achat_immobilier_paris.html">Acheter</a></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="page_vente_appartement_immobilier_paris.html" class="navText">Vendre </a></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="page_louer_immobilier_paris.html" class="navText">Louer </a></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="page_vente_appartement_immobilier_paris.html" class="navText">Faire expertiser </a></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="page_honoraires_agence_immobiliere_low_cost_paris.html" class="navText">Honoraires Low cost </a></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="contact_agence_immobiliere_paris.html" class="navText">Nous contacter </a></td>
</tr>
</table></td>
</tr>
<tr>
<td width="165"><a href="information_agence_paris.html" class="navText">Nous connaître </a></td>
</tr>
<tr>
<td width="165"><a href="lien_immobilier_agence_paris.html" class="navText">Nos liens </a></td>
</tr>
<tr>
<td width="165"><a href="page_recrutement_agent_immobilier_paris.html" class="navText">Nous recrutons </a></td>
</tr>
<tr>
<td width="165"><a href="page_apporteur_d_affaire_parrainez_commission_immobilier_paris.html" class="navText">L'apporteur d'affaire</a></td>
</tr>
<tr>
<td width="165"><a href="outil_immobilier_lexique_juridique.html" class="navText">Outils immobiliers </a></td>
</tr>
</table>
<p align="center"><font size="1" color="black"> </font><u><font size="1" color="white">AGENCE Seloger à Paris</font></u> </p> <h3 align="center"><font size="1" color="white"><b>IDAIS Charles-Henri</b></font> </h3>
<h3 align="center"><font size="1" color="white"><b>Tel: 06-87-25-01-18</b></font></h3>
<h3 align="center"><font size="1" color="white"><b>Mail: contact@seloger-a-paris.fr</b></font></h3>
<h3 align="center"><font size="1" color="white"><b>Site: www.seloger-a-paris.fr</b></font></h3></td>
<td width="50"> </td>
<td width="496" colspan="2" valign="top">
<p align="center"><img src="mm_spacer.gif" alt="" width="305" height="1" border="0" /><br />
 <br />
<table border="0" cellspacing="0" cellpadding="0" width="305">
<tr>
<td class="pageName">
<p align="center">Nous contacter</td>
</tr>
</table>

<table border="0" cellspacing="0" cellpadding="0" width="305">
<tr>
<td class="pageName" height="29">
<p align="justify"> </p></td>
</tr>
</table>
<p align="justify" class="Style1"><strong>Les experts immobiliers de
l'agence Seloger à Paris sont à votre disposition pour réaliser votre projet.</strong></p>
<p align="justify" class="Style1">
<strong>À cet effet, vous pouvez nous contacter, soit par téléphone 06
87 25 01 18,
soit à l'aide du formulaire ci-dessous que nous vous remercions
de remplir avec précision.</strong></p>
<p align="justify" class="Style1"><strong>Nous vous recontacterons sous 24 heures.</strong></p>
<p align="justify">
(Les champs suivis d'une * doivent être obligatoirement complétés) </p>
<div align="justify">
<table border="0" cellpadding="3" cellspacing="0" width="500">
<td>Votre message :</td>
<td width="348">
<p align="justify"> </td>
</tr>
<p align="justify"><strong> <tr>
<td colspan="2" align="left" height="25">
<p align="justify">
<textarea name="Commentaires" rows="6" cols="45"></textarea>
</td>
</tr>
<tr>
<td colspan="2" height="25">
<p align="justify"><strong>Coordonnées : </strong></td>
</tr>
<tr>
<td height="25" width="150">
<p align="justify"><strong>Nom*:</strong></td>
<td height="25">
<p align="justify"><input name="Nom" value="" /></td>
</tr>
<tr>
<td height="25" width="150">
<p align="justify"><strong>Prénom :</strong></td>
<td>
<p align="justify"><input name="Prenom" value="" /></td>
</tr>
<tr>
<td height="36" width="150">
<p align="justify"><strong>Téléphone*:</strong></td>
<td>
<p align="justify"><input size="15" name="Telephone" value="" /> </td>
</tr>
<tr>
<td height="25" width="150">
<p align="justify"><strong>Fax :</strong></td>
<td>
<p align="justify"><input size="15" name="Fax" value="" /></td>
</tr>
<tr>
<td height="25" width="150">
<p align="justify"><strong>E-mail*:</strong></td>
<td>
<p align="justify"><input name="AdresseMail" value="" /></td>
</tr>
</tbody>
</table>
</div>
<p align="center">
<input type="submit" value="Envoyer" name="B1" />
<input type="reset" value="Rétablir" name="B2" />
</p>
<p align="justify">  </p></td>
<td width="64"><img src="mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
<td width="235" valign="top"><p align="center"> </p>
</td>
<td width="20%"> </td>
</tr>
<tr>
<td width="165"><div align="center"><img src="images_site_seloger_a_paris/snpi.gif" width="79" height="69" border="0" alt="Agence SNPI" /></div></td>
<td width="50"> </td>
<td width="244"> </td>
<td width="252"> </td>
<td width="64"> </td>
<td width="235"> </td>
<td width="20%"> </td>
</tr>
</table>
</form>
</body>
</html>

___________________________________________________________________________

voici le code de la page sendmail.php:

<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Agence immobilière LOW COST : Seloger à Paris, estimation immobilière, achat vente, du Château au studio</title>
<meta name="description" content="Agence immobilière seloger à Paris: achat, vente, immobilier d'entrprise à Paris, Ile de France ">
<meta name="keywords" content="achat,vente,location,logement,appartement,immobilier,maison,annonces,immobilières,ventes,vendre,louer,terrain,commerces,parking,seloger-a-paris.com, seloger paris ">
<meta name="author" content="Idais">
<meta name="rating" content="Immobilier - Paris - achat- vente"><!-- DEBUT DU SCRIPT -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="mm_health_nutr.css" type="text/css" />
<script language="JavaScript" type="text/javascript">
//--------------- LOCALIZEABLE GLOBALS---------------
var d=new Date();
monthname= new Array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
//--------------- END LOCALIZEABLE ---------------
</script></head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#D5EDB3">
<td width="382" colspan="3" rowspan="2"><img src="images_site_seloger_a_paris/bando.jpg" width="382" height="101" /></td>
<td width="523" height="50" colspan="3" id="logo" valign="bottom" align="center" nowrap="nowrap">Seloger-à-Paris.<em>fr</em></td>
<td width="28%"> </td>
</tr>

<tr bgcolor="#D5EDB3">
<td height="51" colspan="3" id="tagline" valign="top" align="center" width="523">Du studio au Château</td>
<td width="28%"> </td>
</tr>

<tr>
<td colspan="7" bgcolor="#5C743D" width="1260"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
</tr>

<tr>
<td colspan="7" bgcolor="#99CC66" background="mm_dashed_line.gif" width="1260"><img src="mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
</tr>

<tr bgcolor="#99CC66">
<td colspan="7" id="dateformat" height="20" width="1260">  <script language="JavaScript" type="text/javascript">
document.write(TODAY); </script> </td>
</tr>
<tr>
<td colspan="7" bgcolor="#99CC66" background="mm_dashed_line.gif" width="1260"><img src="mm_dashed_line.gif" alt="line decor" width="4" height="3" border="0" /></td>
</tr>

<tr>
<td colspan="7" bgcolor="#5C743D" width="1260"><img src="mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
</tr>

<tr>
<td width="165" valign="top" bgcolor="#5C743D">
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"> <br />
 <br /> <table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165">  <table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="index.html">Accueil</a></td>
</tr>
</table></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="page_achat_immobilier_paris.html">Acheter</a></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="page_vente_appartement_immobilier_paris.html">Vendre</a></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="javascript:;" class="navText">Louer </a></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="javascript:;" class="navText">Faire expertiser </a></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="javascript:;" class="navText">Honoraires Low cost </a></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
<tr>
<td width="165"><a href="javascript:;" class="navText">Nous contacter </a></td>
</tr>
</table></td>
</tr>
<tr>
<td width="165"><a href="javascript:;" class="navText">Nous connaître </a></td>
</tr>
<tr>
<td width="165"><a href="javascript:;" class="navText">Nos liens </a></td>
</tr>
<tr>
<td width="165"><a href="javascript:;" class="navText">Nous recrutons </a></td>
</tr>
<tr>
<td width="165"><a href="javascript:;" class="navText">L'apporteur d'affaire</a></td>
</tr>
<tr>
<td width="165"><a href="javascript:;" class="navText">Outils immobiliers </a></td>
</tr>
</table>
<p align="center"><font size="1" color="black"> </font><u><font size="1" color="white">AGENCE Seloger à Paris</font></u> </p> <h3 align="center"><font size="1" color="white"><b>IDAIS Charles-Henri</b></font> </h3>
<h3 align="center"><font size="1" color="white"><b>Tel: 06-87-25-01-18</b></font></h3>
<h3 align="center"><font size="1" color="white"><b>Mail: contact@seloger-a-paris.fr</b></font></h3>
<h3 align="center"><font size="1" color="white"><b>Site: www.seloger-a-paris.fr</b></font></h3></td>
<td width="50"><img src="mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
<td width="305" colspan="2" valign="top">
<p align="center"><img src="mm_spacer.gif" alt="" width="305" height="1" border="0" /><br />
 <br />
<table border="0" cellspacing="0" cellpadding="0" width="305">
<tr>
<td class="pageName">
<p align="center">Vous souhaitez vendre </td>
</tr>
</table>

<table border="0" cellspacing="0" cellpadding="0" width="305">
<tr>
<td class="pageName" height="28">
<p align="center"> </p>
</td>
</tr>
</table>
<table align="center" border="0" width="500">
<tbody>
<tr>
<td> </td>
</tr>
</tbody>
</table>
<p> Merci </p>
<p> </p>
<p><?php
$TO = "contact@seloger-a-paris.fr";

$h = "From: " . $TO;

$message = "";

while (list($key, $val) = each($HTTP_POST_VARS)) {
$message .= "$key : $val\n";
}

mail($TO, $subject, $message, $h);

Header("Location: http://www.seloger-a-paris.fr/merci_mail.html<URL de la page de remerciement>");

?>
 </p>
<p> </p>
<p> </p></td>
<td width="82"><img src="mm_spacer.gif" alt="" width="50" height="1" border="0" /></td>
<td width="303" valign="top"><p align="center"> </p>
<p align="left"><b>    </b></p>
</td>
<td width="28%"> </td>
</tr>
<tr>
<td width="165"> </td>
<td width="50"> </td>
<td width="167"> </td>
<td width="138"> </td>
<td width="82"> </td>
<td width="303"> </td>
<td width="28%"> </td>
</tr>
</table>
</body>
</html>

_____________________________________________________________________________

J'ai placé les adresses des pages afin d'eviter cette longue page de code, ce dernier etant visible derrire la page web.


Merci
0
chaspli Messages postés 45 Date d'inscription mardi 31 juillet 2007 Statut Membre Dernière intervention 11 juin 2011
26 janv. 2010 à 16:07
Super !

Merci de vos explications très pragmatiques. Je viens de corriger les erreurs, et cela fonctionne très bien. I me manque plus qu'a ajouter une versification du formulaire en javascript afin de limiter les spam...

Concernant le code type pour la page index.php, merci aussi. Effectivement cela va être d'une grande utilité...



Désolé pour ce problème simpliste, mais j'ai une formation immobilière,...le "webmastering" c'est encore une découverte pour moi ;-)

A bientôt
C-H
0