I'm trying to make a very basic contact form in PHP. I'm using MAMP to test it. For some reason, however, the form doesn't work: when I fill in the form and press the "submit" button, I am redirected to index.html?mailsend but I don't receive any email! What am I doing wrong?
my HTML code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="contactform.php" method="POST">
<input type="text" name="name" placeholder="Full Name">
<input type="text" name="mail" placeholder="Your e-mail">
<input type="text" name="subject" placeholder="Subject">
<textarea name="message" placeholder="Message"></textarea>
<button type="submit" name="submit">Send e-mail</button>
</form>
</body>
</html>
my PHP code:
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$subject = $_POST['subject'];
$mailFrom = $_POST['mail'];
$message = $_POST['message'];
$mailTo = "tomms1998@gmail.com";
$headers = "From: ".$mailFrom;
$txt = "You have received an e-mail from ".$name.".\n\n".$message;
mail($mailTo, $subject, $txt, $headers);
header("Location: index.html?mailsend");
}
?>