0

I have been looking for over a week for a contact form that is not too complicated to understand and create.

I finally found this contact form that seemed to be simple and easy to understand with HTML and PHP.

The issue is that once i click the submit button the email never arrived to my personal email on gmail.

The goal: Create a working contact form with HTML and PHP

The issue: Email never arrived when submitted

I would really appreciate if someone could help me out indicating what the problem could be and how to fix it, thank you!

The form is divided into three parts, here is my code -->

contact.php :

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Contact Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<form action="thankyou.php" method="post">

Name <input type="text" name="fullname">
Email <input type="text" name="email">
Message <textarea name="message"></textarea>

<input type="submit" value="Send">
</form>

</body>
</html>

thankyou.php :

<?
$name = $_POST['fullname'];
$email = $_POST['email'];
$message = $_POST['message'];

$email_message = "
Name: ".$name."
Email: ".$email."
Message ".$message."

";

mail("myemail@gmail.com" , "New inquiry" , $email_message);
header("Location: email_success.php");

?>

email_success.php :

<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Email Sent</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<h1>Email sent</h1>

</body>
</html>
user5434403
  • 157
  • 2
  • 11
  • 1
    Did you configure your e-mail account ( the account that the e-mail would be sent from) ? – malutki5200 Dec 12 '16 at 12:41
  • 1
    I recommend using a library such as PHPMailer, though. But look at the dupe, should give you some clarity - most likely it's missing headers and that's causing some sort of filtering on the receiver end. Does the `mail()` function even return `true` in your `thankyou.php`? – Qirel Dec 12 '16 at 12:41
  • 1
    In your `php.ini` you should configure how to send your mail. Search about `mail` in the fil, you can use sendmail that work fine to configure it with an email account. – Anthony Dec 12 '16 at 12:43
  • 1
    If you want to use default PHP mail function `mail()`, then you have to configure it. http://www.quackit.com/php/tutorial/php_mail_configuration.cfm – Aniket Singh Dec 12 '16 at 12:44
  • Thank you all for the quick answers, I will have a proper look at how to configure the php.ini – user5434403 Dec 12 '16 at 13:14

0 Answers0