0

can anyone please help me with my code, I try to send email with form submission I don't get any error but also no mail recive this is my code

<?php
if (isset($_POST['submit'])) {
$to = "my.email@gmail.com";
$from=$_POST['email'];
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$subject="Form submission";
$message=$first_name." ".$last_name." wrote the       following:"."\n\n".$_POST['message'];
$headers="From:".$from;
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you ".$first_name." we will contact you shortly.";
header("Location: ../pages/home.html"); /* Redirect browser */
exit();
}
?>

and this is my form

<form id="formContact" action="../php/email.php" method="post">
<fieldset>
Nume:<br>
<input id="firstname" type="text" name="first_name" required >
<br>
Prenume:<br>
<input id="lastname" type="text" name="last_name" required >
<br>
Email:<br>
<input id="email" type="email" name="email" required >
<br>
Mesaj:<br>
<textarea id="mesage" name="message" required>
</textarea>
<br>
<br>
<input id="buttonOK" type="submit" value="OK" name="submit">
</fieldset>
</form>
  • What is the result of the `mail()` function? What is the response from the SMTP server? There are *many* reasons why a particular email might not end up in your inbox, few of which have much of anything to do with your code. – David Dec 28 '15 at 21:34
  • try closing your input tags ../> – Juakali92 Dec 28 '15 at 21:44
  • Are you certain that you have an smtp service (such as postfix) installed on your server? – ohiodoug Dec 28 '15 at 21:46
  • Most emails sent from mail would go to your spam box. i have changed the to email to may email address and i managed to receive the email in my spam box. – katwekibs Dec 28 '15 at 21:52

0 Answers0