1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| <?php
$enable_html = "on";
if ($mode == "submit") {
if ($enable_html != "on") {
/*
Les utilisateurs peuvent ou non envoyer le mail au format HTML
*/
$mail_body = htmlspecialchars ($mail_body);
}
// On construit les entetes
$headers .= "MIME-Version: 1.0 \n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \n";
$headers .= "from:$mail_from\r\nCc:$mail_cc\r\nBcc:$mail_bcc";
/*
La fonction mail retourne TRUE si l envoi reussi ou FALSE si il échoue, donc on verifie le resultat
*/
if (@mail ($mail_to, $mail_subject, $mail_body, $headers)) {
print ("<h1><font color=\"#004000\">Email envoyé avec succès!</font></h1>");
} else {
print ("<h1><font color=\"#880000\">Une erreur est apparue lors de l'envoi. Echec!</font></h1>");
}
// On n'a plus besoin de voir le formulaire
exit;
}
?>
<html>
<head>
<title>Send e-mail</title>
<script language="javascript">
function DoSubmit ()
{
/*
Cette fonction verifie que les champs important on été remplis correctement
Le return "" annule l'envoi du formulaire en cas d erreur
*/
if (document.form.mail_from.value == "") {
alert ("Vous avez oublié le champ 'De'.");
document.form.mail_from.focus ();
return "";
}
if (document.form.mail_to.value == "") {
alert ("Vous avez oublié le champ 'A'..");
document.form.mail_to.focus ();
return "";
}
if (document.form.mail_subject.value == "") {
alert ("Vous avez oublié le champ 'Sujet'.");
document.form.mail_subject.focus ();
return "";
}
if (document.form.mail_body.value == "") {
alert ("Vous avez oublié le champ 'Message'.");
document.form.mail_body.focus ();
return "";
}
document.form.submit ();
}
</script>
<?php $mail_from = "infoPasSpam@le-chocolat.fr";?>
</head>
<body>
<!--
$PHP_SELF permet au formulaire de marcher meme si vous renommez ce fichier
-->
<form action="<?php print ($PHP_SELF); ?>" method="post" name="form">
<table>
<tr>
<td>De:</td>
<td><input type="text" name="mail_from" size="40" value="<?php echo $mail_from ?>"</td>
</tr>
<tr>
<td>A:</td>
<td><input type="text" name="mail_to" size="40"</td>
</tr>
<td>Sujet:</td>
<td><input type="text" name="mail_subject" size="40" value="Bonjour."</td>
</tr>
<tr>
<td valign="top">Message:</td>
<td><textarea name="mail_body" cols="50" rows="20">Suivre le lien
<a href=\"http://www.le-site.fr\">ICI</a>//Pb ici
</textarea></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><input type="hidden" name="mode" value="submit"></td>
<td><input type="button" onclick="DoSubmit ()" value="Send e-mail"></td>
</tr>
</table>
</form>
</body>
</html> |
Partager