0

My code did work few minutes ago. I didn't change anything, I just tried again for tests, now nothing is working. I just wanted to do a very simple form to email :

HTML

<form action="mail.php" method="post" id="inscription">
    <input name="nom" type="text" id="nom" placeholder="Nom">
    <input name="prenom" type="text" id="prenom" placeholder="Prénom">
    <input name="email" type="email" id="email" placeholder="E-mail">
    <input name="tel" type="tel" id="tel" placeholder="01.23.45.67.89">
    <input name="company" type="text" id="company" placeholder="Nom de l'entreprise">
    <input name="nb-personne" type="text" id="nb-personne" placeholder="Nombre de personne">
    <textarea name="comment" cols="15" rows="6" id="comment"></textarea>
    <input type="submit" name="Submit" value="JE M'INSCRIS*" class="submit">
</form>

PHP

$ToEmail = 'ptusseau@histrasbourg.com'; 
$EmailSubject = 'Inscription SOIREE BRESILIENNE<hr/>'; 
$mailheader = "From: ".$_POST["email"]."\r\n"; 
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .="MIME-Version: 1.0\r\n";
$mailheader .="Content-type: text/html; charset=utf=8\r\n";

$MESSAGE_BODY = "Nom: ".$_POST["nom"]."";
$MESSAGE_BODY .= "Prénom: ".$_POST["prenom"].""; 
$MESSAGE_BODY .= "Email: ".$_POST["email"].""; 
$MESSAGE_BODY .= "Tél: ".$_POST["tel"].""; 
$MESSAGE_BODY .= "Entreprise: ".$_POST["company"].""; 
$MESSAGE_BODY .= "Nombre de personne: ".$_POST["nb-personne"]."";
$MESSAGE_BODY .= "Commentaire: ".nl2br($_POST["comment"])."";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader); 

// METTRE UN MERCI.HTML 
include("merci.html");
exit(0);

I wanted to make a simple email, with
in HTML just before any new line (prenom, email, tel, etc.). But I don't know how to do, I don't understand .nl2br actually ... And it doesn't send an email anymore, anyway.

  • Well does it give an error, what does mail return (it returns boolean true or false).. – Naruto Oct 17 '14 at 09:50
  • No error, it loads correctly merci.html and that's all. No mail. I tried on 3 inbox, everything works perfectly, but not my code :( I don't get how return true or false ... on what ? – Pierre Tusseau Oct 17 '14 at 10:42

1 Answers1

0
  • Inspect, verify and filter POST data to see whether data is coming through correctly
  • Verify you can send mails from the server you are using and configuration (SMTP etc.) is correctly set up
  • Consider using a mail library instead of manually working with error-prone mail headers, body contents and all that is involved
  • Your emails might be classified as spam and thus not getting through
Community
  • 1
  • 1
Elias
  • 1,532
  • 8
  • 19
  • Also, you are not securing the input ? Maybe the quote caracter is the problem ? You should at least have a `addslashes` function around your `$_POST`. – Yves Lange Oct 17 '14 at 09:52
  • Could you help me to inspect the POST data ? Actually I've near no knowledge of PHP. I just wanted to send a basic mail... I thought this was possible. And I HAVE to succeed, it's my first job in my company :( – Pierre Tusseau Oct 17 '14 at 10:15
  • When I ECHO my "$_POST["nom"]" or anything else, it works ... I guess this is mail() which doesn't work. – Pierre Tusseau Oct 17 '14 at 10:35