Probleme formulaire email php
wifi
-
Nabla's Messages postés 18201 Date d'inscription Statut Contributeur Dernière intervention -
Nabla's Messages postés 18201 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
voila j ai un formulaire php qui me sert de newsletter mais quand je renseigne l email il me met "form sending impossible" je ne vois pas pourquoi
merci de votre aide
<?php
// N'afficher que les erreurs, pas les avertissements...
ini_set("error_reporting", "E_ALL & ~E_NOTICE");
// Adresse de réception du formulaire
$email_dest = "test@test.com";
if ($_POST['envoi']) {
// E-mail headers:
$headers ="MIME-Version: 1.0 \n";
$headers .="From: Customers<test@test.com>\n";
$headers .="Content-Type: text/html; charset=iso-8859-1 \n";
$subject = "Inscription newsletter";
$partie_entete = "<html><head>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
</head>
<body bgcolor=#FCE1AA>";
for ($a=1; $a<= $_POST['nbre_champs_texte']; $a++)
if ($_POST['nbre_zone_email'] != 0) {
$partie_zone_email = "<font face='Verdana' size='2' color='#8e1a2c'>" . $_POST['titre_email'] . " = " . $_POST['zone_email'] . "</font><br>";
}
$fin = "</body></html>";
$sortie = $partie_entete . $partie_champs_texte . $partie_zone_email . $partie_zone_texte . $fin;
// Send the e-mail
if (@!mail($email_dest,$subject,$sortie,$headers)) {
echo("Forms sending impossible");
} else { // Closing if !mail...
// Renvoi à la page de remerciement
header("Location:thanks");
exit();
} // Fin du else
} // Closing if edit
?><html><head><title></title><script language="JavaScript">function verifSelection() {if (document.mail_form.champ1.value == "") {
alert("Required information")
return false
} if (document.mail_form.champ1.value == "") {
alert("Required information")
return false
}
invalidChars = " /:,;'"
for (i=0; i<invalidChars.length; i++) { // does it contain any invalid characters?
badChar = invalidChars.charAt(i)
if (document.mail_form.zone_email.value.indexOf(badChar,0) > -1) {
alert("Invalid Character. Please check.")
document.mail_form.zone_email.focus()
return false
}
}
atPos = document.mail_form.zone_email.value.indexOf("@",1) // there must be one "@" symbol
if (atPos == -1) {
alert('Please enter "@".')
document.mail_form.zone_email.focus()
return false
}
if (document.mail_form.zone_email.value.indexOf("@",atPos+1) != -1) { // and only one "@" symbol
alert('only one "@" symbol. Please check.')
document.mail_form.zone_email.focus()
return false
}
periodPos = document.mail_form.zone_email.value.indexOf(".",atPos)
if (periodPos == -1) { // and at least one "." after the "@"
alert('and at least one "." after the "@". Please check.')
document.mail_form.zone_email.focus()
return false
}
if (periodPos+3 > document.mail_form.zone_email.value.length) { // must be at least 2 characters after the
alert('must be at least 2 characters after the ".". Please check.')
document.mail_form.zone_email.focus()
return false
}} // Fin de la fonction
</script>
</head>
<body>
<form name="mail_form" method="post" action="" onSubmit="return verifSelection()">
<div align="center"></div>
<p align="center">
<table width="566" border="0" align="center">
<p align="center">
</p><tr>
<td width><font face="Verdana" color="8e1a2c" size="2">E mail *</font></td>
<td width><input name="zone_email" type="text"></td>
</tr><tr>
<td valign="top"><input name="nbre_champs_texte" type="hidden" id="nbre_champs_texte" value="1">
<input name="nbre_zones_texte" type="hidden" value="1">
<input name="nbre_zone_email" type="hidden" value="1">
<input name="titre_email" type="hidden" value="E mail"></td>
<td><div align="center">
<input type="reset" name="Reset" value="Reset">
<input type="submit" name="envoi" value="Send">
</div></td>
</tr>
</table>
<div align="center"></div>
<div align="left">
<span style="color: #8e1a2c;">
* Mandatory fields
</span>
</div>
</form></body></html>
voila j ai un formulaire php qui me sert de newsletter mais quand je renseigne l email il me met "form sending impossible" je ne vois pas pourquoi
merci de votre aide
<?php
// N'afficher que les erreurs, pas les avertissements...
ini_set("error_reporting", "E_ALL & ~E_NOTICE");
// Adresse de réception du formulaire
$email_dest = "test@test.com";
if ($_POST['envoi']) {
// E-mail headers:
$headers ="MIME-Version: 1.0 \n";
$headers .="From: Customers<test@test.com>\n";
$headers .="Content-Type: text/html; charset=iso-8859-1 \n";
$subject = "Inscription newsletter";
$partie_entete = "<html><head>
<meta http-equiv=Content-Type content=text/html; charset=iso-8859-1>
</head>
<body bgcolor=#FCE1AA>";
for ($a=1; $a<= $_POST['nbre_champs_texte']; $a++)
if ($_POST['nbre_zone_email'] != 0) {
$partie_zone_email = "<font face='Verdana' size='2' color='#8e1a2c'>" . $_POST['titre_email'] . " = " . $_POST['zone_email'] . "</font><br>";
}
$fin = "</body></html>";
$sortie = $partie_entete . $partie_champs_texte . $partie_zone_email . $partie_zone_texte . $fin;
// Send the e-mail
if (@!mail($email_dest,$subject,$sortie,$headers)) {
echo("Forms sending impossible");
} else { // Closing if !mail...
// Renvoi à la page de remerciement
header("Location:thanks");
exit();
} // Fin du else
} // Closing if edit
?><html><head><title></title><script language="JavaScript">function verifSelection() {if (document.mail_form.champ1.value == "") {
alert("Required information")
return false
} if (document.mail_form.champ1.value == "") {
alert("Required information")
return false
}
invalidChars = " /:,;'"
for (i=0; i<invalidChars.length; i++) { // does it contain any invalid characters?
badChar = invalidChars.charAt(i)
if (document.mail_form.zone_email.value.indexOf(badChar,0) > -1) {
alert("Invalid Character. Please check.")
document.mail_form.zone_email.focus()
return false
}
}
atPos = document.mail_form.zone_email.value.indexOf("@",1) // there must be one "@" symbol
if (atPos == -1) {
alert('Please enter "@".')
document.mail_form.zone_email.focus()
return false
}
if (document.mail_form.zone_email.value.indexOf("@",atPos+1) != -1) { // and only one "@" symbol
alert('only one "@" symbol. Please check.')
document.mail_form.zone_email.focus()
return false
}
periodPos = document.mail_form.zone_email.value.indexOf(".",atPos)
if (periodPos == -1) { // and at least one "." after the "@"
alert('and at least one "." after the "@". Please check.')
document.mail_form.zone_email.focus()
return false
}
if (periodPos+3 > document.mail_form.zone_email.value.length) { // must be at least 2 characters after the
alert('must be at least 2 characters after the ".". Please check.')
document.mail_form.zone_email.focus()
return false
}} // Fin de la fonction
</script>
</head>
<body>
<form name="mail_form" method="post" action="" onSubmit="return verifSelection()">
<div align="center"></div>
<p align="center">
<table width="566" border="0" align="center">
<p align="center">
</p><tr>
<td width><font face="Verdana" color="8e1a2c" size="2">E mail *</font></td>
<td width><input name="zone_email" type="text"></td>
</tr><tr>
<td valign="top"><input name="nbre_champs_texte" type="hidden" id="nbre_champs_texte" value="1">
<input name="nbre_zones_texte" type="hidden" value="1">
<input name="nbre_zone_email" type="hidden" value="1">
<input name="titre_email" type="hidden" value="E mail"></td>
<td><div align="center">
<input type="reset" name="Reset" value="Reset">
<input type="submit" name="envoi" value="Send">
</div></td>
</tr>
</table>
<div align="center"></div>
<div align="left">
<span style="color: #8e1a2c;">
* Mandatory fields
</span>
</div>
</form></body></html>
Configuration: Windows Vista Firefox 3.0.10
2 réponses
-
// Send the e-mail
if (@!mail($email_dest,$subject,$sortie,$headers)) {
echo("Forms sending impossible");
} else { // Closing if !mail...
donc visiblement ca vient de la fonction mail en php ..
es ce que tu as bien défini ton serveur SMTP dans ton php.ini ?
sinon, tu peux le faire grace a ini_set (que tu utilises deja)
--> si tu héberge toi meme ton serveur, il faut mettre le smtp de ton fournisseur d'accès internet
si tu héberge en ligne, tout les hébergeurs n'autorisent pas l'utilisation de leur smtp. freee l'autorise avec quelques limitations (1000 mails par semaine je croi) -
si , je croi qu'il y a quelques limitations, c'est tout...
mais bon, ils changent souvent leur politique ....