Hamza
Hamza

Reputation: 49

Why is my php script is not sending email?

i am trying to send a feedback message to my email address '[email protected]', the scripts are running properly and but i have not receiving email. please tell me what is the problem..

html:

<html>
  <body>
    <form action="email.php" method="post">
      <input type="text" id="name" value="name" name="name"/><br>
      <input type="text" id="email" value="email" name="email"/><br>
      <input type="text" id="comment" value="comment" name="comment"/><br>
      <input type="submit" value="submit"/>
    </form>
  </body>
</html>

php:

<?php


    $emailSubject = 'my first mail';
    $webMaster = '[email protected]';

    $emailField = $_POST['email'];
    $nameField = $_POST['name'];
    $commentField = $_POST['comment'];

    $body = <<<EOD
    <br><hr><br>
    Email: $email <br>
    Name: $name <br>
    Comments: $comment <br>
    EOD;

    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);

    $theResults = <<<EOD
      <html>
        <body>
          Thank you for your feed back
        </body>
      </html>
    EOD;
    echo "$theResults";

?>

Upvotes: 0

Views: 221

Answers (1)

Benjamin Eckstein
Benjamin Eckstein

Reputation: 894

most localhosts dont support emailing out of the box.

try to upload this script to your webhost and it should be fine.

the code looks ok.

Upvotes: 2

Related Questions