0

I have the following php code on my HTML page:

<body>
 <?php
        if ($_POST) {
            $message = 'Name :' . $_POST['name'] . "\n" .
                    'Email :' . $_POST['email'] . "\n" .
                    'Phone :' . $_POST['phone'] . "\n" .
                    'Date :' . $_POST['book'] . "\n" .
                    'Message :' . $_POST['message'];
            mail('ruan@gmail.com', 'Contact-us Form', $message);
        }
        ?>

And HTML as the following:

<form method="post" action="contact.php" onsubmit="return valid()" enctype="multipart/form-data">
      <ul>

        <li>
          <p class="left">
            <p>Name</p>
            <input type="text" name="name" placeholder="John Doe" />
          </p>
   .....
 </form>

Now i have changed the email address to check if that could be the problem but still, I don't receive any email.

user3588641
  • 21
  • 1
  • 5

1 Answers1

0

I think you need to include headers for php mail function

<?php
  $to      = 'nobody@example.com';
  $subject = 'the subject';
  $message = 'hello';
  $headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

 mail($to, $subject, $message, $headers);
?>

check out this link http://php.net/manual/en/function.mail.php.

If still not working check your smtp setting for your server. If also not working then use phpmailer. Check out this link for phpmailer http://phpmailer.worxware.com/?pg=examples

Codelord
  • 1,120
  • 2
  • 10
  • 21